feat: writer (#24) #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tag Logger | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
env: | |
GIT_USER_EMAIL: ${{ secrets.GIT_EMAIL }} | |
GIT_USER_NAME: ${{ secrets.GIT_NAME }} | |
jobs: | |
tag_adapter: | |
if: "!startsWith(github.event.head_commit.message, 'bump:')" | |
name: Tag logger | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
ref: "main" | |
- name: Fetch tags | |
run: git fetch --tags origin '+refs/tags/v*:refs/tags/v*' | |
- name: Files modified | |
id: check | |
run: | | |
any_changed="false" | |
if git diff --name-only HEAD^ | grep -q "^internal/"; then | |
any_changed="true" | |
fi | |
# check if any go file in root folder change | |
if git diff --name-only HEAD^ | grep -E "^([a-z0-9_]+\.go)$|^(go\.(mod|sum))$"; then | |
any_changed="true" | |
fi | |
echo "any_changed=$any_changed" >> $GITHUB_OUTPUT | |
- name: Config Git User | |
if: steps.check.outputs.any_changed == 'true' | |
run: | | |
git config --local user.email "$GIT_USER_EMAIL" | |
git config --local user.name "$GIT_USER_NAME" | |
git config --local pull.ff only | |
- name: Setup Python | |
if: steps.check.outputs.any_changed == 'true' | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install commitizen | |
if: steps.check.outputs.any_changed == 'true' | |
run: pip install -U commitizen | |
- name: Pull changes | |
if: steps.check.outputs.any_changed == 'true' | |
run: git fetch --tags origin '+refs/tags/v*:refs/tags/v*' | |
- id: cz | |
name: Create bump and changelog | |
if: steps.check.outputs.any_changed == 'true' | |
working-directory: ${{ matrix.module }} | |
run: | | |
python -m pip install -U commitizen | |
cz bump --yes | |
export REV=`cz version --project` | |
echo "version=$REV" >> $GITHUB_OUTPUT | |
- name: Push changes | |
if: steps.check.outputs.any_changed == 'true' | |
uses: Woile/github-push-action@master | |
with: | |
github_token: ${{ secrets.ACCESS_TOKEN }} | |
tags: "true" | |
branch: "main" | |
- name: Print Version | |
if: steps.check.outputs.any_changed == 'true' | |
run: echo "Bumped to version ${{ steps.cz.outputs.version }}" |