|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: release-${{ github.ref }} |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup Python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: "3.11" |
| 28 | + |
| 29 | + - name: Build dependencies |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install build |
| 33 | +
|
| 34 | + - name: Build artifacts |
| 35 | + run: python -m build |
| 36 | + |
| 37 | + - name: Smoke-test built wheel |
| 38 | + run: | |
| 39 | + set -euo pipefail |
| 40 | + wheel=(dist/*.whl) |
| 41 | + if [ "${#wheel[@]}" -ne 1 ]; then |
| 42 | + echo "Expected exactly one wheel artifact in dist/" >&2 |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | +
|
| 46 | + python -m venv /tmp/azurefox-release-smoke-venv |
| 47 | + /tmp/azurefox-release-smoke-venv/bin/pip install "${wheel[0]}" |
| 48 | + /tmp/azurefox-release-smoke-venv/bin/azurefox help >/dev/null |
| 49 | + AZUREFOX_FIXTURE_DIR=tests/fixtures/lab_tenant \ |
| 50 | + /tmp/azurefox-release-smoke-venv/bin/azurefox \ |
| 51 | + --outdir /tmp/azurefox-release-smoke \ |
| 52 | + --output json \ |
| 53 | + whoami \ |
| 54 | + >/dev/null |
| 55 | +
|
| 56 | + - name: Upload release artifacts |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: release-dist |
| 60 | + path: dist/* |
| 61 | + if-no-files-found: error |
| 62 | + |
| 63 | + github-release: |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: build |
| 66 | + permissions: |
| 67 | + contents: write |
| 68 | + steps: |
| 69 | + - name: Download release artifacts |
| 70 | + uses: actions/download-artifact@v4 |
| 71 | + with: |
| 72 | + name: release-dist |
| 73 | + path: dist |
| 74 | + |
| 75 | + - name: Publish GitHub release |
| 76 | + env: |
| 77 | + GH_TOKEN: ${{ github.token }} |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + assets=(dist/*) |
| 81 | + if [ "${#assets[@]}" -eq 0 ]; then |
| 82 | + echo "No release assets found in dist/" >&2 |
| 83 | + exit 1 |
| 84 | + fi |
| 85 | +
|
| 86 | + if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then |
| 87 | + gh release upload "${GITHUB_REF_NAME}" "${assets[@]}" --clobber |
| 88 | + else |
| 89 | + gh release create "${GITHUB_REF_NAME}" "${assets[@]}" \ |
| 90 | + --generate-notes \ |
| 91 | + --title "${GITHUB_REF_NAME}" \ |
| 92 | + --verify-tag |
| 93 | + fi |
| 94 | +
|
| 95 | + pypi-publish: |
| 96 | + runs-on: ubuntu-latest |
| 97 | + needs: build |
| 98 | + environment: |
| 99 | + name: pypi |
| 100 | + permissions: |
| 101 | + id-token: write |
| 102 | + steps: |
| 103 | + - name: Download release artifacts |
| 104 | + uses: actions/download-artifact@v4 |
| 105 | + with: |
| 106 | + name: release-dist |
| 107 | + path: dist |
| 108 | + |
| 109 | + - name: Publish to PyPI via Trusted Publishing |
| 110 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 111 | + with: |
| 112 | + packages-dir: dist/ |
0 commit comments