diff --git a/.github/workflows/update-major-version-tag.yml b/.github/workflows/update-major-version-tag.yml new file mode 100644 index 00000000..c07e8648 --- /dev/null +++ b/.github/workflows/update-major-version-tag.yml @@ -0,0 +1,64 @@ +name: Update Major Version Tag + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + workflow_dispatch: + inputs: + tag: + description: 'The full version tag to process (e.g., v13.1.0)' + required: true + type: string + +jobs: + update-major-tag: + name: Update Major Version Tag + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get tag name + id: get-tag + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + TAG="${{ inputs.tag }}" + else + TAG="${GITHUB_REF#refs/tags/}" + fi + echo "tag=$TAG" >> $GITHUB_OUTPUT + # Extract major version (e.g., v13 from v13.1.0) + MAJOR_TAG=$(echo "$TAG" | sed -E 's/^(v[0-9]+)\..*/\1/') + echo "major_tag=$MAJOR_TAG" >> $GITHUB_OUTPUT + + - name: Update major version tag + run: | + TAG="${{ steps.get-tag.outputs.tag }}" + MAJOR_TAG="${{ steps.get-tag.outputs.major_tag }}" + + echo "Processing tag: $TAG" + echo "Major version tag: $MAJOR_TAG" + + # Configure git + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + # Get the commit SHA for the pushed tag + COMMIT_SHA=$(git rev-list -n 1 "$TAG") + echo "Commit SHA: $COMMIT_SHA" + + # Delete the major tag locally if it exists + git tag -d "$MAJOR_TAG" 2>/dev/null || true + + # Create/update the major version tag pointing to the same commit + git tag "$MAJOR_TAG" "$COMMIT_SHA" + + # Force push the major version tag to origin + git push origin "$MAJOR_TAG" --force + + echo "Successfully updated $MAJOR_TAG to point to $TAG ($COMMIT_SHA)" diff --git a/README.md b/README.md index a356b3e1..0ca0155f 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,15 @@ jobs: For more application cases please check [Smoke Test Workflow file](https://github.com/DeLaGuardo/setup-clojure/blob/main/.github/workflows/smoke-tests.yml) +# Versioning + +You can reference this action using either: + +- **Full version** (e.g., `DeLaGuardo/setup-clojure@13.4.0`) - pins to a specific release +- **Major version** (e.g., `DeLaGuardo/setup-clojure@v13`) - automatically receives all minor and patch updates within that major version + +Using the major version tag is recommended for most users, as it ensures you receive bug fixes and new features without breaking changes. + # License The scripts and documentation in this project are released under the [MIT License](LICENSE)