Files
pda-fieldbus-profiles/.gitea/workflows/auto-tag.yml
T
TomUvi 3545abfa36
Auto Tag / tag (push) Successful in 2s
CI / validate (push) Failing after 3s
Auto Tag / release (push) Successful in 22s
fix: tag bump on tagless repo by walking full HEAD range
git describe falls back to literal "v0.0.0" when no tags exist; the
subsequent git log v0.0.0..HEAD then fails silently and the workflow
skips, so the very first feat: commit never produces a tag.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 13:50:16 +02:00

102 lines
2.7 KiB
YAML

name: Auto Tag
on:
push:
branches: [main]
permissions:
contents: write
jobs:
tag:
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.bump.outputs.new_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version bump and create tag
id: bump
run: |
if LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
RANGE="${LATEST_TAG}..HEAD"
else
LATEST_TAG="v0.0.0"
RANGE="HEAD"
fi
echo "Latest tag: $LATEST_TAG"
COMMITS=$(git log "$RANGE" --pretty=format:"%s")
if [ -z "$COMMITS" ]; then
echo "No new commits since ${LATEST_TAG}, skipping."
exit 0
fi
BUMP=""
if echo "$COMMITS" | grep -qiE "^[a-z]+(\(.+\))?!:|BREAKING CHANGE"; then
BUMP="major"
elif echo "$COMMITS" | grep -qiE "^feat(\(.+\))?:"; then
BUMP="minor"
elif echo "$COMMITS" | grep -qiE "^fix(\(.+\))?:"; then
BUMP="patch"
fi
if [ -z "$BUMP" ]; then
echo "No conventional commit triggers, skipping."
exit 0
fi
VERSION="${LATEST_TAG#v}"
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
case "$BUMP" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
echo "Creating tag: $NEW_TAG"
git tag "$NEW_TAG"
git push origin "$NEW_TAG"
echo "new_tag=$NEW_TAG" >> "$GITHUB_OUTPUT"
release:
needs: tag
if: needs.tag.outputs.new_tag != ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.new_tag }}
- uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: false
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.41.3
- name: Build .deb
run: |
VER="${{ needs.tag.outputs.new_tag }}"
VER="${VER#v}"
mkdir -p dist
VERSION="$VER" nfpm pkg --packager deb --target dist/ -f nfpm.yaml
ls -la dist/
- name: Publish .deb to repo.pda.cz
run: |
for deb in dist/*.deb; do
echo "Uploading $deb"
curl --fail -X POST https://repo.pda.cz/api/v1/PDAT/main/upload \
-H "Authorization: Bearer ${{ secrets.PDA_REPO_TOKEN }}" \
-F "file=@${deb}"
done