From aa158ad09058bf12cc1f372ee17992d6e169dfe3 Mon Sep 17 00:00:00 2001 From: Nicolas Varrot Date: Thu, 12 Feb 2026 14:44:33 +0000 Subject: [PATCH] ci: add release workflow with semver Docker tags and GitHub Releases - New release.yml: triggers on v* tags, builds/pushes Docker with vX.Y.Z, vX.Y, vX, latest tags, creates GitHub Release with changelog - Updated docker.yml: main pushes now tag as 'edge' (dev) instead of 'latest' - latest tag is now only set by the release workflow on version tags --- .github/workflows/docker.yml | 4 +- .github/workflows/release.yml | 103 ++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3e6c88d..82c76b1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,6 +3,8 @@ name: Docker on: push: branches: [main] + tags-ignore: + - 'v*' jobs: build-and-push: @@ -27,7 +29,7 @@ jobs: with: images: ghcr.io/${{ github.repository }} tags: | - type=raw,value=latest + type=raw,value=edge type=sha,prefix= - name: Build and push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ba8a78f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,103 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use Node.js 22 + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint + + - name: Type check + run: npx tsc --noEmit + + - name: Build + run: npm run build + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract version from tag + id: version + run: | + TAG="${GITHUB_REF#refs/tags/}" + VERSION="${TAG#v}" + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f1-2) + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "major=v$MAJOR" >> "$GITHUB_OUTPUT" + echo "minor=v$MINOR" >> "$GITHUB_OUTPUT" + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{ steps.version.outputs.tag }} + ghcr.io/${{ github.repository }}:${{ steps.version.outputs.minor }} + ghcr.io/${{ github.repository }}:${{ steps.version.outputs.major }} + labels: | + org.opencontainers.image.version=${{ steps.version.outputs.version }} + + - name: Generate changelog excerpt + id: changelog + run: | + # Get commits since previous tag + PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") + if [ -n "$PREV_TAG" ]; then + RANGE="${PREV_TAG}..HEAD" + else + RANGE="HEAD" + fi + { + echo "changelog<> "$GITHUB_OUTPUT" + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.tag }} + name: ${{ steps.version.outputs.tag }} + body: | + ## What's Changed + + ${{ steps.changelog.outputs.changelog }} + + ## Docker + + ```bash + docker pull ghcr.io/marlburrow/pinchchat:${{ steps.version.outputs.tag }} + ``` + draft: false + prerelease: false