From 4437daabc3eb0b3faa22b18de76e34f2b50da4c2 Mon Sep 17 00:00:00 2001 From: jmeridth Date: Fri, 4 Apr 2025 01:48:04 -0500 Subject: [PATCH] feat: major version updater Updates the major version to point to the latest published tag with the same major tag Example: v2.2.0 exists v2 is currently pointed to v2.2.0 release happens v2.3.0 is created this action will point v2 at the new v2.3.0 Signed-off-by: jmeridth --- .github/workflows/major-version-updater.yaml | 33 +++++++++++++++++++ .../workflows/test-major-version-updater.yaml | 19 +++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/major-version-updater.yaml create mode 100644 .github/workflows/test-major-version-updater.yaml diff --git a/.github/workflows/major-version-updater.yaml b/.github/workflows/major-version-updater.yaml new file mode 100644 index 0000000..a8ec77f --- /dev/null +++ b/.github/workflows/major-version-updater.yaml @@ -0,0 +1,33 @@ +--- +name: "Major Version Updater" +on: + workflow_call: + inputs: + tag_name: + required: true + type: string +permissions: + contents: read +jobs: + major_version_updater: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4.2.2 + with: + fetch-tags: true + ref: ${{ inputs.tag_name }} + - name: version + id: version + env: + TAG_NAME: ${{ inputs.tag_name }} + run: | + tag=${TAG_NAME/refs\/tags\//} + version=${tag#v} + major=${version%%.*} + { echo "tag=${tag}"; echo "version=${version}"; echo "major=${major}"; } >> "$GITHUB_OUTPUT" + - name: force update major tag + run: | + git tag -f v${{ steps.version.outputs.major }} ${{ steps.version.outputs.tag }} + git push -f origin v${{ steps.version.outputs.major }} diff --git a/.github/workflows/test-major-version-updater.yaml b/.github/workflows/test-major-version-updater.yaml new file mode 100644 index 0000000..20e00d0 --- /dev/null +++ b/.github/workflows/test-major-version-updater.yaml @@ -0,0 +1,19 @@ +--- +name: "Test Major Version Updater" +on: + release: + types: [published] + workflow_dispatch: + inputs: + TAG_NAME: + description: "Tag name that the major tag will point to (e.g. v1.2.3)" + required: true +permissions: + contents: read +jobs: + labeler: + permissions: + contents: write + uses: ./.github/workflows/major-version-updater.yaml + with: + tag_name: ${{ github.event.inputs.TAG_NAME || github.ref}}