Skip to content

feat(ci): add Homebrew tap automated publishing #3

feat(ci): add Homebrew tap automated publishing

feat(ci): add Homebrew tap automated publishing #3

Workflow file for this run

name: Auto Tag
on:
push:
branches:
- main
paths:
- "Cargo.toml"
permissions:
contents: write
jobs:
auto-tag:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.version.outputs.tag }}
tag_exists: ${{ steps.tagcheck.outputs.exists }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Read version
id: version
shell: bash
run: |
set -euo pipefail
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
if [ -z "$VERSION" ]; then
echo "Failed to read version from Cargo.toml" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Check if tag exists
id: tagcheck
shell: bash
run: |
set -euo pipefail
TAG="${{ steps.version.outputs.tag }}"
if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Update README versions
if: steps.tagcheck.outputs.exists == 'false'
shell: bash
run: |
set -euo pipefail
bash scripts/update-readme-version.sh "${{ steps.version.outputs.version }}"
rm -f README.md.bak README_ZH.md.bak
- name: Commit README update (if needed)
if: steps.tagcheck.outputs.exists == 'false'
shell: bash
run: |
set -euo pipefail
if ! git diff --quiet README.md README_ZH.md; then
git add README.md README_ZH.md
git commit -m "chore: Update version to ${{ steps.version.outputs.tag }}"
git push origin HEAD:main
else
echo "No README changes to commit."
fi
- name: Create and push tag
if: steps.tagcheck.outputs.exists == 'false'
shell: bash
run: |
set -euo pipefail
TAG="${{ steps.version.outputs.tag }}"
git tag "$TAG"
git push origin "$TAG"
release:
needs: auto-tag
if: needs.auto-tag.outputs.tag_exists == 'false'
uses: ./.github/workflows/release.yml
with:
tag: ${{ needs.auto-tag.outputs.tag }}
secrets: inherit
permissions:
contents: write