From e57d6071350c83187070671a977e3f54eb0e681d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 13 Sep 2024 21:56:45 -0400 Subject: [PATCH] feat: add workflow to bump version in ci Version bumps are done via git tagging, which can be annoying to do locally as I would need to lookup the last release. Instead, automate the actual workflow so that it can be bumped in CI. Ideally version bumps are done on PR merge and automatically computed, but this workflow is fine for now. --- .github/workflows/bump-version.yaml | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/bump-version.yaml diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml new file mode 100644 index 0000000..9894bf2 --- /dev/null +++ b/.github/workflows/bump-version.yaml @@ -0,0 +1,52 @@ +--- +name: "bump-version" + +# yamllint disable-line rule:truthy +on: + workflow_dispatch: + inputs: + bump_type: + description: "Bump type" + default: "patch" + required: true + type: choice + options: + - patch + - minor + - major + +env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + +jobs: + bump-version: + name: bump-version + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4.1.4 + with: + fetch-depth: 0 + token: ${{ env.GITHUB_ACCESS_TOKEN }} + + - name: Get Latest Tag + id: latest-tag + run: | + echo GIT_LATEST_TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)")" >>"$GITHUB_OUTPUT" + + - name: Compute Next Tag + id: next-tag + uses: docker://ghcr.io/dokku/semver-generator:latest + with: + bump: ${{ github.event.inputs.bump_type }} + input: ${{ steps.latest-tag.outputs.GIT_LATEST_TAG }} + + - name: Create and Push Tag + run: | + git config --global user.name 'Dokku Bot' + git config --global user.email no-reply@dokku.com + git tag "$GIT_NEXT_TAG" + git push origin "$GIT_NEXT_TAG" + env: + GIT_NEXT_TAG: ${{ steps.next-tag.outputs.version }}