Bump version to 6.1.1 #71
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and upload to PyPI and create GitHub release | |
| # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| tags: | |
| - "[0-9]+.[0-9]+.[0-9]+*" # Push events for official release tags | |
| - "test-release/[0-9]+.[0-9]+.[0-9]+*" # Push events for test release tags | |
| jobs: | |
| # Call the reusable build workflow to build both PyPI and Conda artifacts | |
| build: | |
| name: Build distribution artifacts | |
| uses: ./.github/workflows/_build.yml | |
| # Job that pushes dist artifacts to public PyPI for official release tags | |
| official-pypi-publish: | |
| name: Upload official release to PyPI | |
| # Prevent running on test-release tags | |
| if: startsWith(github.ref, 'refs/tags/test-release') == false | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: official-pypi-publish-environment | |
| url: https://pypi.org/p/space_packet_parser # Public PyPI | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| steps: | |
| # This downloads the build artifacts from the build job | |
| - name: Download distribution artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@v1.13.0 | |
| # Job that pushes dist artifacts to TestPyPI for test release tags | |
| test-pypi-publish: | |
| name: Upload testing release to TestPyPI | |
| # Only run on test-release tags | |
| if: startsWith(github.ref, 'refs/tags/test-release') | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: test-pypi-publish-environment | |
| url: https://test.pypi.org/p/space_packet_parser # TestPyPI | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| steps: | |
| # This downloads the build artifacts from the build job | |
| - name: Download distribution artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@v1.13.0 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| # Job that publishes Conda package to Anaconda.org | |
| anaconda-publish: | |
| name: Publish Anaconda package | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: conda-publish-environment | |
| steps: | |
| - name: Download Conda artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: conda-package | |
| path: conda-package/ | |
| - name: Setup Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| channels: conda-forge,defaults | |
| auto-update-conda: true | |
| python-version: "3.11" | |
| - name: Publish to Anaconda | |
| shell: bash -l {0} | |
| env: | |
| # We set "--channel test-release" if the tag starts with refs/tags/test-release | |
| ANACONDA_CHANNEL_OPTION: ${{ startsWith(github.ref, 'refs/tags/test-release') && '--channel test-release' || '' }} | |
| ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | |
| run: | | |
| conda install -y anaconda-client | |
| anaconda upload --user ${{ vars.ANACONDA_USER_NAME }} $ANACONDA_CHANNEL_OPTION conda-package/**/space_packet_parser-*.conda | |
| # Job that publishes a release to GitHub | |
| create-github-release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: create-github-release-environment | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for sigstore | |
| contents: write # IMPORTANT: mandatory for making GitHub Releases | |
| steps: | |
| - name: Determine if the release is a prerelease | |
| # Checks the regex form of the tag to see if there is a suffix after the semver | |
| # Marks final releases only for tags matching the regex (no version suffixes) | |
| # All other releases are marked as prereleases | |
| # Sets the behavior by setting the PRE_RELEASE_OPTION environment variable in the GITHUB_ENV file. | |
| # Note: This environment variable is only available to later steps via the ${{ env.PRE_RELEASE_OPTION }} | |
| # syntax | |
| run: | | |
| if [[ ${{ github.ref_name }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "PRE_RELEASE_OPTION=''" >> $GITHUB_ENV # Not a prerelease | |
| else | |
| echo "PRE_RELEASE_OPTION=--prerelease" >> $GITHUB_ENV # Is a prerelease | |
| fi | |
| - name: Get latest non-prerelease release | |
| # This fetches the "latest" (non-prerelease) release ref, | |
| # so we can generate release notes from that point instead of the most recent prerelease. | |
| # Sets LATEST_RELEASE environment variable in the GITHUB_ENV file | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| latest_release=$(gh release list --repo "${{ github.repository }}" --limit 100 --json tagName,isPrerelease --jq '.[] | select(.isPrerelease == false) | .tagName' | head -n 1) | |
| if [ -z "$latest_release" ]; then | |
| echo "No non-prerelease release found." | |
| exit 1 | |
| fi | |
| echo "LATEST_RELEASE_TAG=$latest_release" >> $GITHUB_ENV | |
| - name: Create GitHub Release | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| # Uses the GitHub CLI to generate the Release and auto-generate the release notes. Also generates | |
| # the Release title based on the annotation on the git tag. | |
| run: >- | |
| RELEASE_NAME=$(basename "${{ github.ref_name }}") | |
| gh release create | |
| '${{ github.ref_name }}' | |
| --repo '${{ github.repository }}' | |
| --title "$RELEASE_NAME" | |
| ${{ env.PRE_RELEASE_OPTION }} | |
| --generate-notes | |
| --notes-start-tag '${{ env.LATEST_RELEASE_TAG }}' |