|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + id-token: write |
| 12 | + packages: write |
| 13 | + attestations: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + environment: production |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: "3.12" |
| 25 | + |
| 26 | + - uses: astral-sh/setup-uv@v5 |
| 27 | + with: |
| 28 | + version: "0.6.9" |
| 29 | + |
| 30 | + - name: Set version |
| 31 | + run: | |
| 32 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 33 | + echo "VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" |
| 34 | + else |
| 35 | + echo "VERSION=workflow-${GITHUB_RUN_ID}" >> "$GITHUB_ENV" |
| 36 | + fi |
| 37 | +
|
| 38 | + - name: Build wheel and sdist |
| 39 | + run: uv build |
| 40 | + |
| 41 | + - name: Attest distribution artifacts |
| 42 | + if: github.event_name == 'push' |
| 43 | + uses: actions/attest-build-provenance@v2 |
| 44 | + with: |
| 45 | + subject-path: | |
| 46 | + dist/*.whl |
| 47 | + dist/*.tar.gz |
| 48 | +
|
| 49 | + - name: Test wheel installation |
| 50 | + run: | |
| 51 | + python -m venv /tmp/nc-venv |
| 52 | + /tmp/nc-venv/bin/pip install --upgrade pip |
| 53 | + /tmp/nc-venv/bin/pip install dist/*.whl |
| 54 | + /tmp/nc-venv/bin/python -m noisecutter --help |
| 55 | +
|
| 56 | + - name: Set up Docker Buildx |
| 57 | + uses: docker/setup-buildx-action@v3 |
| 58 | + |
| 59 | + - name: Build Docker image |
| 60 | + run: | |
| 61 | + docker build -t "ghcr.io/${{ github.repository }}/noisecutter:${{ env.VERSION }}" . |
| 62 | + docker build -t "ghcr.io/${{ github.repository }}/noisecutter:latest" . |
| 63 | +
|
| 64 | + - name: Test Docker image |
| 65 | + run: docker run --rm "ghcr.io/${{ github.repository }}/noisecutter:${{ env.VERSION }}" --help |
| 66 | + |
| 67 | + - name: Log in to GHCR |
| 68 | + if: github.event_name == 'push' |
| 69 | + uses: docker/login-action@v3 |
| 70 | + with: |
| 71 | + registry: ghcr.io |
| 72 | + username: ${{ github.actor }} |
| 73 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + - name: Push Docker image |
| 76 | + if: github.event_name == 'push' |
| 77 | + run: | |
| 78 | + docker push "ghcr.io/${{ github.repository }}/noisecutter:${{ env.VERSION }}" |
| 79 | + docker push "ghcr.io/${{ github.repository }}/noisecutter:latest" |
| 80 | +
|
| 81 | + - name: Publish to PyPI |
| 82 | + if: github.event_name == 'push' |
| 83 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 84 | + with: |
| 85 | + packages-dir: dist/ |
| 86 | + skip-existing: true |
| 87 | + |
| 88 | + - name: Create GitHub Release |
| 89 | + if: github.event_name == 'push' |
| 90 | + uses: softprops/action-gh-release@v2 |
| 91 | + with: |
| 92 | + files: dist/* |
| 93 | + generate_release_notes: true |
| 94 | + draft: false |
| 95 | + prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }} |
0 commit comments