|
| 1 | +name: "Run CD" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + force_release: |
| 7 | + description: 'Force release even if previous checks fail.' |
| 8 | + type: boolean |
| 9 | + required: false |
| 10 | + default: false |
| 11 | + |
| 12 | +env: |
| 13 | + UV_FROZEN: "1" |
| 14 | + CICD: 1 |
| 15 | + |
| 16 | +jobs: |
| 17 | + code-checks: |
| 18 | + uses: ./.github/workflows/quality.yml |
| 19 | + pre-release-check: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 # for fetching tags, required for semantic-release |
| 27 | + - name: Install uv and set the python version |
| 28 | + uses: astral-sh/setup-uv@v5 |
| 29 | + with: |
| 30 | + enable-cache: true |
| 31 | + - name: Install dependencies |
| 32 | + run: uv sync --only-dev |
| 33 | + - name: Check version of potential release |
| 34 | + id: version_check |
| 35 | + run: | |
| 36 | + TRGT_VERSION=$(uv run --no-sync semantic-release print-version) |
| 37 | + echo "TRGT_VERSION=${TRGT_VERSION}" >> "$GITHUB_OUTPUT" |
| 38 | + echo "${TRGT_VERSION}" |
| 39 | + - name: Check notes of potential release |
| 40 | + run: uv run --no-sync semantic-release changelog --unreleased |
| 41 | + release: |
| 42 | + needs: [code-checks, pre-release-check] |
| 43 | + # Run this job only if the `TARGET_TAG_V` is set AND (the previous jobs |
| 44 | + # were successful OR we are forcing the release). |
| 45 | + if: >- |
| 46 | + ${{ needs.pre-release-check.outputs.TARGET_TAG_V != '' && |
| 47 | + ( success() || inputs.force_release ) }} |
| 48 | + environment: auto-release |
| 49 | + runs-on: ubuntu-latest |
| 50 | + concurrency: release |
| 51 | + steps: |
| 52 | + - uses: actions/create-github-app-token@v1 |
| 53 | + id: app-token |
| 54 | + with: |
| 55 | + app-id: ${{ vars.CI_APP_ID }} |
| 56 | + private-key: ${{ secrets.CI_PRIVATE_KEY }} |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + token: ${{ steps.app-token.outputs.token }} |
| 60 | + fetch-depth: 0 # for fetching tags, required for semantic-release |
| 61 | + - name: Install uv and set the python version |
| 62 | + uses: astral-sh/setup-uv@v5 |
| 63 | + with: |
| 64 | + enable-cache: true |
| 65 | + - name: Install dependencies |
| 66 | + run: uv sync --only-dev |
| 67 | + - name: Run release script |
| 68 | + env: |
| 69 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 70 | + TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }} |
| 71 | + CHGLOG_FILE: CHANGELOG.md |
| 72 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 73 | + run: ./.github/scripts/release.sh |
| 74 | + shell: bash |
0 commit comments