-
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (86 loc) · 3.06 KB
/
deploy.yml
File metadata and controls
99 lines (86 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Deploy
on:
workflow_dispatch:
schedule:
# Every Friday at 16:00 UTC; the gate job filters to even ISO weeks so
# the stable release runs at most once every two weeks.
- cron: '0 16 * * 5'
jobs:
gate:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
should_release: ${{ steps.gate.outputs.should_release }}
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Decide whether to release
id: gate
run: |
if [ "${{ github.event_name }}" != "schedule" ]; then
echo "Manual dispatch; proceeding."
echo "should_release=true" >> $GITHUB_OUTPUT
exit 0
fi
WEEK=$((10#$(date -u +%V)))
if [ $((WEEK % 2)) -ne 0 ]; then
echo "ISO week $WEEK is odd; biweekly release runs only on even weeks. Skipping."
echo "should_release=false" >> $GITHUB_OUTPUT
exit 0
fi
VERSION=$(awk -F= '/^version=/{print $2}' src/resources/app.properties)
TAG="v${VERSION}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists; version has not been bumped since last release. Skipping."
echo "should_release=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Even ISO week $WEEK with unreleased version $VERSION; proceeding."
echo "should_release=true" >> $GITHUB_OUTPUT
deploy:
needs: gate
if: needs.gate.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Read version from app.properties
id: version
run: |
VERSION=$(awk -F= '/^version=/{print $2}' src/resources/app.properties)
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: tag
run: |
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Fail if tag already exists
if: steps.tag.outputs.exists == 'true'
run: |
echo "::error::Tag ${{ steps.version.outputs.tag }} already exists. Bump the version in src/resources/app.properties."
exit 1
- name: Create and push tag
if: steps.tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.version.outputs.tag }}
git push origin ${{ steps.version.outputs.tag }}
- uses: actions/setup-go@v6.3.0
with:
go-version: "1.25.5"
- uses: goreleaser/goreleaser-action@v7.0.0
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TOKEN }}