-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (171 loc) · 7.8 KB
/
Copy pathrelease.yml
File metadata and controls
186 lines (171 loc) · 7.8 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g. v1.1.0)'
required: true
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Run tests
run: ./gradlew test
build-linux:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify version matches tag
# Only enforce on real tag pushes; workflow_dispatch is used for rc tags
# (e.g. v1.2.0-rc1) which intentionally won't match the build.gradle.kts version.
if: github.event_name == 'push'
run: |
GRADLE_VER=$(grep '^version = ' build.gradle.kts | sed 's/version = "\(.*\)"/\1/')
TAG_VER=${GITHUB_REF_NAME#v}
if [ "${GRADLE_VER}" != "${TAG_VER}" ]; then
echo "Tag ${GITHUB_REF_NAME} does not match build.gradle.kts version ${GRADLE_VER}"
exit 1
fi
- name: Build native image
run: ./gradlew nativeCompile
- name: Smoke test
run: |
./build/native/nativeCompile/localdevstack --service go --database postgres --output /tmp/s1 --name t
test -f /tmp/s1/service/main.go && test -f /tmp/s1/docker-compose.yml
mkdir /tmp/ex && echo 'module test' > /tmp/ex/go.mod
./build/native/nativeCompile/localdevstack --existing-dir /tmp/ex --database postgres
test -f /tmp/ex/Dockerfile.dev && test -f /tmp/ex/docker-compose.yml
- name: Package artifact
run: |
VERSION=${GITHUB_REF_NAME#v}
cp build/native/nativeCompile/localdevstack localdevstack-linux-x64
tar czf localdevstack-${VERSION}-linux-x64.tar.gz localdevstack-linux-x64
sha256sum localdevstack-${VERSION}-linux-x64.tar.gz > localdevstack-${VERSION}-linux-x64.tar.gz.sha256
- uses: actions/upload-artifact@v4
with:
name: linux-x64
path: localdevstack-*-linux-x64.tar.gz*
# build-macos-x64 was removed when GitHub retired the macos-13 runner image
# (only the latest two macOS versions stay supported, and no free Intel macOS
# runner exists in its place). Apple stopped selling Intel Macs in 2023, so
# arm64-only macOS coverage is the trade-off; Intel mac users build from
# source via `brew install --build-from-source localdevstack`.
build-macos-arm64:
needs: test
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build native image
run: ./gradlew nativeCompile
# No smoke test on macOS — see build-macos-x64 above for rationale.
- name: Package artifact
run: |
VERSION=${GITHUB_REF_NAME#v}
cp build/native/nativeCompile/localdevstack localdevstack-macos-arm64
tar czf localdevstack-${VERSION}-macos-arm64.tar.gz localdevstack-macos-arm64
shasum -a 256 localdevstack-${VERSION}-macos-arm64.tar.gz > localdevstack-${VERSION}-macos-arm64.tar.gz.sha256
- uses: actions/upload-artifact@v4
with:
name: macos-arm64
path: localdevstack-*-macos-arm64.tar.gz*
build-windows:
needs: test
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
# native-image on Windows shells out to cl.exe / link.exe and needs the
# MSVC developer environment loaded. setup-graalvm's `native-image-msvc`
# flag is unreliable on windows-latest (still fails with "vcvarsall.bat
# not found"). ilammy/msvc-dev-cmd directly invokes vcvarsall.bat and
# exports the env vars to the rest of the job, which works consistently.
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Build native image
run: ./gradlew nativeCompile
- name: Package artifact
shell: pwsh
run: |
$VERSION = $env:GITHUB_REF_NAME -replace '^v', ''
Copy-Item build/native/nativeCompile/localdevstack.exe localdevstack-windows-x64.exe
Compress-Archive localdevstack-windows-x64.exe "localdevstack-${VERSION}-windows-x64.zip"
$hash = (Get-FileHash "localdevstack-${VERSION}-windows-x64.zip" -Algorithm SHA256).Hash.ToLower()
"${hash} localdevstack-${VERSION}-windows-x64.zip" | Out-File -Encoding utf8 "localdevstack-${VERSION}-windows-x64.zip.sha256"
- uses: actions/upload-artifact@v4
with:
name: windows-x64
path: localdevstack-*-windows-x64.zip*
publish:
needs: [build-linux, build-macos-arm64, build-windows]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist/
- name: Publish to distribution repo
env:
DIST_TOKEN: ${{ secrets.DIST_TOKEN }}
GH_TOKEN: ${{ secrets.DIST_TOKEN }}
run: |
VERSION=${GITHUB_REF_NAME#v}
# Create release in the public distribution repo
gh release create "$GITHUB_REF_NAME" \
--repo krishgok/localdevstack \
--title "LocalDevelopmentStack v${VERSION}" \
--generate-notes \
dist/*
# Update Homebrew formula (arm64 macOS + linux-x64; Intel macOS was
# dropped when the macos-13 runner was retired — see build job above).
SHA_ARM64=$(cat dist/localdevstack-${VERSION}-macos-arm64.tar.gz.sha256 | awk '{print $1}')
SHA_LINUX=$(cat dist/localdevstack-${VERSION}-linux-x64.tar.gz.sha256 | awk '{print $1}')
git clone https://x-access-token:${DIST_TOKEN}@github.com/krishgok/localdevstack.git dist-repo/
cd dist-repo
sed -i "s/version \".*\"/version \"${VERSION}\"/" Formula/localdevstack.rb
sed -i "s|url \".*macos-arm64.*\"|url \"https://github.com/krishgok/localdevstack/releases/download/v${VERSION}/localdevstack-${VERSION}-macos-arm64.tar.gz\"|" Formula/localdevstack.rb
sed -i "s/sha256 \".*\" # arm64/sha256 \"${SHA_ARM64}\" # arm64/" Formula/localdevstack.rb
sed -i "s|url \".*linux-x64.*\"|url \"https://github.com/krishgok/localdevstack/releases/download/v${VERSION}/localdevstack-${VERSION}-linux-x64.tar.gz\"|" Formula/localdevstack.rb
sed -i "s/sha256 \".*\" # linux-x64/sha256 \"${SHA_LINUX}\" # linux-x64/" Formula/localdevstack.rb
# Update Scoop manifest
SHA_WIN=$(cat ../dist/localdevstack-${VERSION}-windows-x64.zip.sha256 | awk '{print $1}')
python3 -c "
import json
with open('bucket/localdevstack.json') as f: m = json.load(f)
m['version'] = '${VERSION}'
m['architecture']['64bit']['url'] = 'https://github.com/krishgok/localdevstack/releases/download/v${VERSION}/localdevstack-${VERSION}-windows-x64.zip'
m['architecture']['64bit']['hash'] = '${SHA_WIN}'
with open('bucket/localdevstack.json', 'w') as f: json.dump(m, f, indent=2)
print('Updated Scoop manifest')
"
git config user.email "release-bot@localdevstack.io"
git config user.name "Release Bot"
git add Formula/localdevstack.rb bucket/localdevstack.json
git commit -m "localdevstack v${VERSION}"
git push