Skip to content

Merge pull request #18 from vim89/ci-toon4s #2

Merge pull request #18 from vim89/ci-toon4s

Merge pull request #18 from vim89/ci-toon4s #2

Workflow file for this run

# Auto tag - Automated semantic versioning based on conventional commits
# Mirrors toon4s setup for FlowForge
name: Auto tag
on:
push:
branches: [main]
concurrency:
group: auto-tag-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
actions: write
jobs:
auto-tag:
name: Create semantic version tag
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip release]')"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check and clean incomplete releases
id: check_release
uses: actions/github-script@v7
with:
script: |
const tags = await github.rest.repos.listTags({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 10
});
for (const tag of tags.data) {
try {
await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag.name
});
console.log(`Release exists for tag ${tag.name}`);
} catch (error) {
if (error.status === 404) {
console.log(`No release found for tag ${tag.name}, deleting tag`);
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `tags/${tag.name}`
});
console.log(`Deleted tag ${tag.name}`);
}
}
}
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
tag_prefix: v
release_branches: main
custom_release_rules: |
feat:minor:Features,
fix:patch:Bug Fixes,
docs:patch:Documentation,
chore:patch:Chores,
refactor:patch:Refactoring,
perf:patch:Performance,
test:patch:Tests,
build:patch:Build System,
ci:patch:CI/CD,
revert:patch:Reverts
- name: Trigger release workflow
if: steps.tag_version.outputs.new_tag != ''
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createDispatchEvent({
owner: context.repo.owner,
repo: context.repo.repo,
event_type: 'release-tag-created',
client_payload: {
tag: '${{ steps.tag_version.outputs.new_tag }}'
}
});
- name: Summary
if: steps.tag_version.outputs.new_tag != ''
run: |
echo "## Tag Created Successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**New Tag**: \`${{ steps.tag_version.outputs.new_tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Previous Tag**: \`${{ steps.tag_version.outputs.previous_tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Version Bump**: \`${{ steps.tag_version.outputs.part }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Changelog**:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.tag_version.outputs.changelog }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "🚀 Release workflow triggered via repository_dispatch" >> $GITHUB_STEP_SUMMARY
- name: No tag created
if: steps.tag_version.outputs.new_tag == ''
run: |
echo "## No Tag Created" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "No version bump needed based on commit messages" >> $GITHUB_STEP_SUMMARY