Tagged Release #32
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: Tagged Release | |
| # based on: https://github.com/ArjanCodes/examples/blob/0b8c8ab74908be5ed9239fcdaed875548d3f595c/2024/publish_pypi/release.yaml | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" # v1.2.3 | |
| - "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+" # v1.2.3rc1 | |
| - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" # v1.2.3-rc1 | |
| - "v[0-9]+.[0-9]+.[0-9]+.rc[0-9]+" # v1.2.3.rc1 | |
| jobs: | |
| details: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_version: ${{ steps.release.outputs.new_version }} | |
| suffix: ${{ steps.release.outputs.suffix }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| version_str: ${{ steps.release.outputs.version_str }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract tag and Details | |
| id: release | |
| run: | | |
| if [ "${{ github.ref_type }}" = "tag" ]; then | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| # Strip 'v' prefix if present | |
| VERSION_STR=${TAG_NAME#v} | |
| # Split on hyphen to separate version and suffix | |
| NEW_VERSION=$(echo $VERSION_STR | cut -d'-' -f1) | |
| # Get suffix if exists (everything after the hyphen) | |
| SUFFIX=$(echo "$VERSION_STR" | grep -o '[rd][ec][v1][0-9]*' | tr -d '\n') | |
| echo "version_str=$VERSION_STR" >> "$GITHUB_OUTPUT" | |
| echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT" | |
| echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT" | |
| echo "Version is $VERSION_STR" | |
| echo "Suffix is $SUFFIX" | |
| echo "Tag name is $TAG_NAME" | |
| else | |
| echo "No tag found" | |
| exit 1 | |
| fi | |
| setup_and_build: | |
| needs: | |
| - details | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| version: "0.7.2" | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Setup Python | |
| run: uv python install 3.12 | |
| - name: Build source and wheel distribution | |
| run: | | |
| uv build | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| docs-pass: | |
| needs: [details] | |
| uses: ./.github/workflows/docs.yml | |
| tests-pass: | |
| needs: [details] | |
| uses: ./.github/workflows/test.yml | |
| pypi_publish: | |
| name: Upload release to PyPI | |
| needs: [setup_and_build, details, tests-pass, docs-pass] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| - name: Install soundscapy from TestPyPI | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 5 | |
| max_attempts: 3 | |
| retry_wait_seconds: 30 | |
| command: python -m pip install "soundscapy==${{ needs.details.outputs.version_str }}" | |
| - run: python -c "import soundscapy; print(soundscapy.__version__)" | |
| - name: Install soundscapy[audio] from TestPyPI | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 5 | |
| max_attempts: 3 | |
| retry_wait_seconds: 30 | |
| command: python -m pip install "soundscapy[audio]==${{ needs.details.outputs.version_str }}" | |
| - run: python -c "import soundscapy; print(soundscapy.__version__); from soundscapy import Binaural" | |
| # - name: Install soundscapy[all] from TestPyPI | |
| # uses: nick-fields/retry@v3 | |
| # with: | |
| # timeout_minutes: 5 | |
| # max_attempts: 3 | |
| # retry_wait_seconds: 30 | |
| # command: python -m pip install "soundscapy[all]==${{ needs.details.outputs.version_str }}" | |
| # - run: python -c "import soundscapy; print(soundscapy.__version__); from soundscapy import Binaural" | |
| github_release: | |
| name: Create GitHub Release | |
| needs: [setup_and_build, details, tests-pass, docs-pass] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Create GitHub Release | |
| id: create_release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if [ ! -z "${{ needs.details.outputs.suffix }}" ]; then | |
| gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes --prerelease | |
| else | |
| gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes | |
| fi |