|
| 1 | +name: Rollback release |
| 2 | +on: |
| 3 | + # You can trigger this workflow via workflow dispatch to start a rollback. |
| 4 | + # This will create a draft release that mirrors the release for `rollback-tag`. |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + rollback-tag: |
| 8 | + type: string |
| 9 | + description: "The tag of an old release to roll-back to." |
| 10 | + required: true |
| 11 | + # Only for dry-runs of changes to the workflow. |
| 12 | + push: |
| 13 | + paths: |
| 14 | + - .github/workflows/rollback-release.yml |
| 15 | + |
| 16 | +jobs: |
| 17 | + prepare: |
| 18 | + name: "Prepare release" |
| 19 | + if: github.repository == 'github/codeql-action' |
| 20 | + |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | + uses: .github/workflows/prepare-release.yml |
| 25 | + |
| 26 | + rollback: |
| 27 | + name: "Create rollback release" |
| 28 | + if: github.repository == 'github/codeql-action' |
| 29 | + runs-on: ubuntu-latest |
| 30 | + timeout-minutes: 45 |
| 31 | + |
| 32 | + # Don't set the deployment environment for test runs |
| 33 | + environment: ${{ github.event_name == 'workflow_dispatch' && 'Automation' || '' }} |
| 34 | + |
| 35 | + needs: |
| 36 | + - prepare |
| 37 | + |
| 38 | + permissions: |
| 39 | + contents: write # needed to push to the repo (tags and releases) |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v5 |
| 44 | + with: |
| 45 | + # We usually expect to checkout `inputs.rollback-tag`, but use |
| 46 | + # `needs.prepare.outputs.latest_tag` for testing. |
| 47 | + ref: ${{ inputs.rollback-tag || needs.prepare.outputs.latest_tag }} |
| 48 | + fetch-depth: 0 # Need full history for calculation of diffs |
| 49 | + |
| 50 | + - name: Configure runner for release |
| 51 | + uses: ./.github/actions/release-initialise |
| 52 | + |
| 53 | + - name: Create tags |
| 54 | + shell: bash |
| 55 | + env: |
| 56 | + RELEASE_TAG: ${{ needs.prepare.outputs.version }} |
| 57 | + MAJOR_VERSION_TAG: ${{ needs.prepare.outputs.major_version }} |
| 58 | + run: | |
| 59 | + git tag --annotate "${RELEASE_TAG}" --message "${RELEASE_TAG}" |
| 60 | + git tag --annotate "${MAJOR_VERSION_TAG}" --message "${MAJOR_VERSION_TAG}" --force |
| 61 | +
|
| 62 | + - name: Push tags |
| 63 | + if: github.event_name == 'workflow_dispatch' |
| 64 | + shell: bash |
| 65 | + env: |
| 66 | + RELEASE_TAG: ${{ needs.prepare.outputs.version }} |
| 67 | + MAJOR_VERSION_TAG: ${{ needs.prepare.outputs.major_version }} |
| 68 | + run: | |
| 69 | + git push origin --atomic --force refs/tags/"${RELEASE_TAG}" refs/tags/"${MAJOR_VERSION_TAG}" |
| 70 | +
|
| 71 | + - name: Prepare partial Changelog |
| 72 | + env: |
| 73 | + PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md" |
| 74 | + VERSION: "${{ needs.prepare.outputs.version }}" |
| 75 | + run: | |
| 76 | + python .github/workflows/script/prepare_changelog.py CHANGELOG.md "$VERSION" > $PARTIAL_CHANGELOG |
| 77 | +
|
| 78 | + echo "::group::Partial CHANGELOG" |
| 79 | + cat $PARTIAL_CHANGELOG |
| 80 | + echo "::endgroup::" |
| 81 | +
|
| 82 | + - name: Generate token |
| 83 | + if: github.event_name == 'workflow_dispatch' |
| 84 | + |
| 85 | + id: app-token |
| 86 | + with: |
| 87 | + app-id: ${{ vars.AUTOMATION_APP_ID }} |
| 88 | + private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }} |
| 89 | + |
| 90 | + - name: Create the GitHub release |
| 91 | + if: github.event_name == 'workflow_dispatch' |
| 92 | + env: |
| 93 | + PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md" |
| 94 | + VERSION: "${{ needs.prepare.outputs.version }}" |
| 95 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 96 | + run: | |
| 97 | + # Do not mark this release as latest. The most recent CLI release must be marked as latest. |
| 98 | + # Set as a draft to give us an opportunity to review the rollback release. |
| 99 | + gh release create \ |
| 100 | + "$VERSION" \ |
| 101 | + --latest=false \ |
| 102 | + --draft \ |
| 103 | + --title "$VERSION" \ |
| 104 | + --notes-file "$PARTIAL_CHANGELOG" |
0 commit comments