diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84583fcb..08bbc5f4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,14 +2,26 @@ name: Release on: workflow_dispatch: + inputs: + version: + description: >- + Existing version tag to re-publish (e.g. v0.200.0). + Leave empty to bump and release a new version. + required: false jobs: release: - if: github.ref == 'refs/heads/main' + # This workflow should always be run on main - this is enforced by the + # `release` environment directly but added here for visibility. + # If the workflow fails during publishing, run a new workflow + # with the `version` that needs to be published. + if: github.ref == 'refs/heads/main' && github.run_attempt == '1' + runs-on: ubuntu-latest environment: release permissions: contents: read + steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -22,16 +34,30 @@ jobs: git config user.name "planetscale-actions-bot" git config user.email "60239337+planetscale-actions-bot@users.noreply.github.com" + - name: Checkout existing tag + if: inputs.version != '' + run: git checkout "refs/tags/$VERSION" + env: + VERSION: ${{ inputs.version }} + - name: Bump version and push tag + if: inputs.version == '' id: bump env: GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} run: script/bump-version.sh + - name: Resolve version + id: version + env: + INPUT_VERSION: ${{ inputs.version }} + BUMP_VERSION: ${{ steps.bump.outputs.RELEASE_VERSION }} + run: echo "TAG=${INPUT_VERSION:-$BUMP_VERSION}" >> "$GITHUB_OUTPUT" + - name: Publish artifacts env: GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - GORELEASER_CURRENT_TAG: ${{ steps.bump.outputs.RELEASE_VERSION }} + GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.TAG }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} AUR_KEY: ${{ secrets.AUR_KEY }}