From dc3d4c7405a3ab51e7931944ebd2fc6111577deb Mon Sep 17 00:00:00 2001 From: Daniel Widgren Date: Thu, 12 Feb 2026 08:09:10 +0100 Subject: [PATCH] ci: separate release from CI, add auto-release workflow Move Docker build+push out of erlang.yml into dedicated release.yml. CI now only runs compile, dialyzer, xref, lint on OTP 28.0 / rebar3 3.26.0. Release workflow creates GitHub release + pushes Docker image on merge to main. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/erlang.yml | 38 +----------- .github/workflows/release.yml | 105 ++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 092d996..e0be7c6 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -11,8 +11,8 @@ jobs: strategy: fail-fast: false matrix: - otp: [27.0] - rebar3: [3.23.0] + otp: ['28.0'] + rebar3: ['3.26.0'] steps: - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 @@ -28,37 +28,3 @@ jobs: run: rebar3 xref - name: Run elvis run: rebar3 lint - release: - needs: [build] - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - name: OTP ${{matrix.otp}} / rebar3 ${{matrix.rebar3}} - strategy: - fail-fast: false - matrix: - otp: [27.0] - rebar3: [3.23.0] - steps: - - uses: actions/checkout@v4 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - version: latest - buildkitd-flags: --debug - - name: Build and push - id: docker_build - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ghcr.io/widgrensit/chatli:latest - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cff3bb8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,105 @@ +name: Release + +on: + push: + branches: [main] + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest tag + id: latest_tag + run: | + TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) + echo "tag=${TAG:-v0.0.0}" >> "$GITHUB_OUTPUT" + + - name: Determine version bump + id: bump + run: | + LATEST="${{ steps.latest_tag.outputs.tag }}" + if [ "$LATEST" = "v0.0.0" ]; then + RANGE="HEAD" + else + RANGE="${LATEST}..HEAD" + fi + + COMMITS=$(git log "$RANGE" --pretty=format:"%s" 2>/dev/null || git log --pretty=format:"%s") + + BUMP="none" + while IFS= read -r msg; do + if echo "$msg" | grep -qiE '^[a-z]+(\(.+\))?!:|BREAKING CHANGE'; then + BUMP="major" + break + elif echo "$msg" | grep -qiE '^feat(\(.+\))?:'; then + BUMP="minor" + elif echo "$msg" | grep -qiE '^fix(\(.+\))?:' && [ "$BUMP" != "minor" ]; then + BUMP="patch" + fi + done <<< "$COMMITS" + + if [ "$BUMP" = "none" ] && [ -n "$COMMITS" ]; then + BUMP="patch" + fi + + echo "bump=$BUMP" >> "$GITHUB_OUTPUT" + + - name: Calculate next version + id: next + if: steps.bump.outputs.bump != 'none' + run: | + CURRENT="${{ steps.latest_tag.outputs.tag }}" + CURRENT="${CURRENT#v}" + IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" + + case "${{ steps.bump.outputs.bump }}" in + major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; + minor) MINOR=$((MINOR + 1)); PATCH=0 ;; + patch) PATCH=$((PATCH + 1)) ;; + esac + + echo "version=v${MAJOR}.${MINOR}.${PATCH}" >> "$GITHUB_OUTPUT" + + - name: Create release + if: steps.bump.outputs.bump != 'none' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "${{ steps.next.outputs.version }}" \ + --title "${{ steps.next.outputs.version }}" \ + --generate-notes \ + --latest + + - name: Login to GitHub Container Registry + if: steps.bump.outputs.bump != 'none' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + if: steps.bump.outputs.bump != 'none' + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + if: steps.bump.outputs.bump != 'none' + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + if: steps.bump.outputs.bump != 'none' + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + ghcr.io/widgrensit/chatli:latest + ghcr.io/widgrensit/chatli:${{ steps.next.outputs.version }}