Run CD #25
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: "Run CD" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| force_release: | |
| description: 'Force release even if previous checks fail.' | |
| type: boolean | |
| required: false | |
| default: false | |
| env: | |
| UV_FROZEN: "1" | |
| CICD: 1 | |
| jobs: | |
| code-checks: | |
| uses: ./.github/workflows/quality.yml | |
| # with: | |
| # push_coverage: false | |
| pre-release-check: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # for fetching tags, required for semantic-release | |
| - name: Install uv and set the python version | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: uv sync --only-dev | |
| - name: Check version of potential release | |
| id: version_check | |
| run: | | |
| TRGT_VERSION=$(uv run --no-sync semantic-release print-version) | |
| echo "TRGT_VERSION=${TRGT_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "${TRGT_VERSION}" | |
| - name: Check notes of potential release | |
| run: uv run --no-sync semantic-release changelog --unreleased | |
| release: | |
| needs: [code-checks, pre-release-check] | |
| # Run this job only if the `TARGET_TAG_V` is set AND (the previous jobs | |
| # were successful OR we are forcing the release). | |
| if: >- | |
| ${{ needs.pre-release-check.outputs.TARGET_TAG_V != '' && | |
| ( success() || inputs.force_release ) }} | |
| environment: auto-release | |
| runs-on: ubuntu-latest | |
| concurrency: release | |
| steps: | |
| - uses: actions/create-github-app-token@v1 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.CI_APP_ID }} | |
| private-key: ${{ secrets.CI_PRIVATE_KEY }} | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| fetch-depth: 0 # for fetching tags, required for semantic-release | |
| - name: Install uv and set the python version | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: uv sync --only-dev | |
| - name: Run release script | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }} | |
| CHGLOG_FILE: CHANGELOG.md | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: ./.github/scripts/release.sh | |
| shell: bash |