Skip to content

Commit dc3d4c7

Browse files
Taureclaude
andcommitted
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 <noreply@anthropic.com>
1 parent ad45fef commit dc3d4c7

2 files changed

Lines changed: 107 additions & 36 deletions

File tree

.github/workflows/erlang.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
otp: [27.0]
15-
rebar3: [3.23.0]
14+
otp: ['28.0']
15+
rebar3: ['3.26.0']
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: erlef/setup-beam@v1
@@ -28,37 +28,3 @@ jobs:
2828
run: rebar3 xref
2929
- name: Run elvis
3030
run: rebar3 lint
31-
release:
32-
needs: [build]
33-
if: github.ref == 'refs/heads/main'
34-
runs-on: ubuntu-latest
35-
name: OTP ${{matrix.otp}} / rebar3 ${{matrix.rebar3}}
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
otp: [27.0]
40-
rebar3: [3.23.0]
41-
steps:
42-
- uses: actions/checkout@v4
43-
- name: Login to GitHub Container Registry
44-
uses: docker/login-action@v3
45-
with:
46-
registry: ghcr.io
47-
username: ${{ github.repository_owner }}
48-
password: ${{ secrets.GITHUB_TOKEN }}
49-
- name: Set up QEMU
50-
uses: docker/setup-qemu-action@v3
51-
- name: Set up Docker Buildx
52-
uses: docker/setup-buildx-action@v3
53-
with:
54-
version: latest
55-
buildkitd-flags: --debug
56-
- name: Build and push
57-
id: docker_build
58-
uses: docker/build-push-action@v3
59-
with:
60-
context: .
61-
push: true
62-
tags: ghcr.io/widgrensit/chatli:latest
63-
- name: Image digest
64-
run: echo ${{ steps.docker_build.outputs.digest }}

.github/workflows/release.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
packages: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Get latest tag
20+
id: latest_tag
21+
run: |
22+
TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
23+
echo "tag=${TAG:-v0.0.0}" >> "$GITHUB_OUTPUT"
24+
25+
- name: Determine version bump
26+
id: bump
27+
run: |
28+
LATEST="${{ steps.latest_tag.outputs.tag }}"
29+
if [ "$LATEST" = "v0.0.0" ]; then
30+
RANGE="HEAD"
31+
else
32+
RANGE="${LATEST}..HEAD"
33+
fi
34+
35+
COMMITS=$(git log "$RANGE" --pretty=format:"%s" 2>/dev/null || git log --pretty=format:"%s")
36+
37+
BUMP="none"
38+
while IFS= read -r msg; do
39+
if echo "$msg" | grep -qiE '^[a-z]+(\(.+\))?!:|BREAKING CHANGE'; then
40+
BUMP="major"
41+
break
42+
elif echo "$msg" | grep -qiE '^feat(\(.+\))?:'; then
43+
BUMP="minor"
44+
elif echo "$msg" | grep -qiE '^fix(\(.+\))?:' && [ "$BUMP" != "minor" ]; then
45+
BUMP="patch"
46+
fi
47+
done <<< "$COMMITS"
48+
49+
if [ "$BUMP" = "none" ] && [ -n "$COMMITS" ]; then
50+
BUMP="patch"
51+
fi
52+
53+
echo "bump=$BUMP" >> "$GITHUB_OUTPUT"
54+
55+
- name: Calculate next version
56+
id: next
57+
if: steps.bump.outputs.bump != 'none'
58+
run: |
59+
CURRENT="${{ steps.latest_tag.outputs.tag }}"
60+
CURRENT="${CURRENT#v}"
61+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
62+
63+
case "${{ steps.bump.outputs.bump }}" in
64+
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
65+
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
66+
patch) PATCH=$((PATCH + 1)) ;;
67+
esac
68+
69+
echo "version=v${MAJOR}.${MINOR}.${PATCH}" >> "$GITHUB_OUTPUT"
70+
71+
- name: Create release
72+
if: steps.bump.outputs.bump != 'none'
73+
env:
74+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
run: |
76+
gh release create "${{ steps.next.outputs.version }}" \
77+
--title "${{ steps.next.outputs.version }}" \
78+
--generate-notes \
79+
--latest
80+
81+
- name: Login to GitHub Container Registry
82+
if: steps.bump.outputs.bump != 'none'
83+
uses: docker/login-action@v3
84+
with:
85+
registry: ghcr.io
86+
username: ${{ github.repository_owner }}
87+
password: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Set up QEMU
90+
if: steps.bump.outputs.bump != 'none'
91+
uses: docker/setup-qemu-action@v3
92+
93+
- name: Set up Docker Buildx
94+
if: steps.bump.outputs.bump != 'none'
95+
uses: docker/setup-buildx-action@v3
96+
97+
- name: Build and push Docker image
98+
if: steps.bump.outputs.bump != 'none'
99+
uses: docker/build-push-action@v6
100+
with:
101+
context: .
102+
push: true
103+
tags: |
104+
ghcr.io/widgrensit/chatli:latest
105+
ghcr.io/widgrensit/chatli:${{ steps.next.outputs.version }}

0 commit comments

Comments
 (0)