Repository navigation
243 lines (212 loc) · 7.58 KB
/
Copy pathdodoc-release.yml
File metadata and controls
243 lines (212 loc) · 7.58 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: dodoc Release
on:
push:
tags:
- 'dodoc-v*'
workflow_dispatch:
permissions:
contents: write
jobs:
build-unix:
name: Build dodoc (${{ matrix.os }}-${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- os: macos
arch: arm64
runner: macos-14
artifact: dodoc-macos-arm64
- os: macos
arch: x86_64
runner: macos-14
artifact: dodoc-macos-x86_64
cross: "-target x86_64-apple-macos12"
- os: linux
arch: x86_64
runner: ubuntu-22.04
artifact: dodoc-linux-x86_64
static: true
- os: linux
arch: arm64
runner: ubuntu-22.04-arm
artifact: dodoc-linux-arm64
static: true
steps:
- uses: actions/checkout@v4
- name: Build dodoc
run: |
CXXFLAGS="-O2 -std=c++17"
if [ "${{ matrix.static }}" = "true" ]; then
CXXFLAGS="$CXXFLAGS -static"
fi
if [ -n "${{ matrix.cross }}" ]; then
CXXFLAGS="$CXXFLAGS ${{ matrix.cross }}"
fi
mkdir -p build/dodoc
c++ $CXXFLAGS -Isrc/core -o build/dodoc/dodoc src/cli/dodoc.cpp src/core/dodo_core.cpp
strip build/dodoc/dodoc || true
- name: Smoke test
if: ${{ !matrix.cross }}
run: |
echo 'use "data.csv", clear' | build/dodoc/dodoc
build/dodoc/dodoc --help
- name: Package
run: |
cd build/dodoc
tar czf ../../${{ matrix.artifact }}.tar.gz dodoc
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.tar.gz
build-windows:
name: Build dodoc (windows-x86_64)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build dodoc
run: |
mkdir build\dodoc
cl /O2 /EHsc /std:c++17 /MT /Isrc\core /Fe:build\dodoc\dodoc.exe src\cli\dodoc.cpp src\core\dodo_core.cpp
shell: cmd
- name: Smoke test
run: |
echo use "data.csv", clear | build\dodoc\dodoc.exe
build\dodoc\dodoc.exe --help
shell: cmd
- name: Package
run: Compress-Archive -Path build\dodoc\dodoc.exe -DestinationPath dodoc-windows-x86_64.zip
shell: pwsh
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dodoc-windows-x86_64
path: dodoc-windows-x86_64.zip
release:
name: Create Release
needs: [build-unix, build-windows]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
generate_release_notes: true
update-tap:
name: Update Homebrew tap
needs: [release]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Get version from tag
id: version
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Download release artifacts
run: |
tag="${{ steps.version.outputs.tag }}"
base="https://github.com/codedthinking/dodo/releases/download/${tag}"
for platform in macos-arm64 macos-x86_64 linux-x86_64 linux-arm64; do
curl -fsSL -o "dodoc-${platform}.tar.gz" "${base}/dodoc-${platform}.tar.gz"
done
- name: Compute sha256 hashes
id: sha
run: |
echo "macos_arm64=$(sha256sum dodoc-macos-arm64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "macos_x86_64=$(sha256sum dodoc-macos-x86_64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "linux_x86_64=$(sha256sum dodoc-linux-x86_64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "linux_arm64=$(sha256sum dodoc-linux-arm64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: codedthinking/homebrew-tap
token: ${{ secrets.TAP_TOKEN }}
- name: Update formula
run: |
tag="${{ steps.version.outputs.tag }}"
version="${tag#dodoc-v}"
cat > Formula/dodoc.rb << 'FORMULA'
class Dodoc < Formula
desc "Compile .do files to SQL — standalone dodo compiler"
homepage "https://getdodo.dev"
license "MIT"
version "VERSION_PLACEHOLDER"
on_macos do
if Hardware::CPU.arm?
url "URL_BASE/dodoc-macos-arm64.tar.gz"
sha256 "SHA_MACOS_ARM64"
else
url "URL_BASE/dodoc-macos-x86_64.tar.gz"
sha256 "SHA_MACOS_X86_64"
end
end
on_linux do
if Hardware::CPU.arm?
url "URL_BASE/dodoc-linux-arm64.tar.gz"
sha256 "SHA_LINUX_ARM64"
else
url "URL_BASE/dodoc-linux-x86_64.tar.gz"
sha256 "SHA_LINUX_X86_64"
end
end
def install
bin.install "dodoc"
end
test do
assert_match "dodoc", shell_output("#{bin}/dodoc --version")
end
end
FORMULA
url_base="https://github.com/codedthinking/dodo/releases/download/${tag}"
sed -i "s|VERSION_PLACEHOLDER|${version}|g" Formula/dodoc.rb
sed -i "s|URL_BASE|${url_base}|g" Formula/dodoc.rb
sed -i "s|SHA_MACOS_ARM64|${{ steps.sha.outputs.macos_arm64 }}|g" Formula/dodoc.rb
sed -i "s|SHA_MACOS_X86_64|${{ steps.sha.outputs.macos_x86_64 }}|g" Formula/dodoc.rb
sed -i "s|SHA_LINUX_X86_64|${{ steps.sha.outputs.linux_x86_64 }}|g" Formula/dodoc.rb
sed -i "s|SHA_LINUX_ARM64|${{ steps.sha.outputs.linux_arm64 }}|g" Formula/dodoc.rb
# Remove leading whitespace from heredoc
sed -i 's/^ //' Formula/dodoc.rb
- name: Push to tap
run: |
tag="${{ steps.version.outputs.tag }}"
version="${tag#dodoc-v}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/dodoc.rb
git commit -m "Update dodoc to ${version}"
git push
update-website:
name: Update website version
needs: [release]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout website branch
uses: actions/checkout@v4
with:
ref: website
- name: Get version from tag
id: version
run: |
tag="${GITHUB_REF#refs/tags/}"
echo "version=${tag#dodoc-v}" >> "$GITHUB_OUTPUT"
- name: Update version in description.yml
run: |
sed -i "s/version: .*/version: ${{ steps.version.outputs.version }}/" docs/description.yml
- name: Push to website
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/description.yml
git diff --cached --quiet && exit 0
git commit -m "Bump version to ${{ steps.version.outputs.version }}"
git push origin website