-
Notifications
You must be signed in to change notification settings - Fork 6
205 lines (173 loc) · 7.75 KB
/
Copy pathrelease.yml
File metadata and controls
205 lines (173 loc) · 7.75 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
crates-io:
name: Publish to crates.io
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install esbuild (for harmont-ts bundle)
working-directory: dsls/harmont-ts
run: npm ci
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
# Bump crate versions
sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-util/Cargo.toml
sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-pipeline-ir/Cargo.toml
sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-plugin-protocol/Cargo.toml
sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-plugin-cloud/Cargo.toml
sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-dsl-engine/Cargo.toml
sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm/Cargo.toml
# Rewrite workspace.dependencies pins so dependents resolve to the
# tagged version (cargo publish strips path deps; the version field
# is what consumers will receive).
sed -i "s|hm-util = { path = \"crates/hm-util\", version = \"0.0.0-dev\" }|hm-util = { path = \"crates/hm-util\", version = \"$VERSION\" }|" Cargo.toml
sed -i "s|hm-pipeline-ir = { path = \"crates/hm-pipeline-ir\", version = \"0.0.0-dev\" }|hm-pipeline-ir = { path = \"crates/hm-pipeline-ir\", version = \"$VERSION\" }|" Cargo.toml
sed -i "s|hm-plugin-protocol = { path = \"crates/hm-plugin-protocol\", version = \"0.0.0-dev\" }|hm-plugin-protocol = { path = \"crates/hm-plugin-protocol\", version = \"$VERSION\" }|" Cargo.toml
sed -i "s|hm-plugin-cloud = { path = \"crates/hm-plugin-cloud\", version = \"0.0.0-dev\" }|hm-plugin-cloud = { path = \"crates/hm-plugin-cloud\", version = \"$VERSION\" }|" Cargo.toml
sed -i "s|hm-dsl-engine = { path = \"crates/hm-dsl-engine\", version = \"0.0.0-dev\" }|hm-dsl-engine = { path = \"crates/hm-dsl-engine\", version = \"$VERSION\" }|" Cargo.toml
cargo check --workspace --exclude hm-fixtures
- name: Publish hm-util
run: |
if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-util/$VERSION" > /dev/null 2>&1; then
echo "hm-util@$VERSION already published, skipping"
else
cargo publish -p hm-util --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty
fi
- name: Wait for crates.io index
run: sleep 30
- name: Publish hm-pipeline-ir
run: |
if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-pipeline-ir/$VERSION" > /dev/null 2>&1; then
echo "hm-pipeline-ir@$VERSION already published, skipping"
else
cargo publish -p hm-pipeline-ir --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty
fi
- name: Wait for crates.io index
run: sleep 30
- name: Publish hm-plugin-protocol
run: |
if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-plugin-protocol/$VERSION" > /dev/null 2>&1; then
echo "hm-plugin-protocol@$VERSION already published, skipping"
else
cargo publish -p hm-plugin-protocol --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty
fi
- name: Wait for crates.io index
run: sleep 30
- name: Publish hm-plugin-cloud
run: |
if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-plugin-cloud/$VERSION" > /dev/null 2>&1; then
echo "hm-plugin-cloud@$VERSION already published, skipping"
else
cargo publish -p hm-plugin-cloud --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty
fi
- name: Wait for crates.io index
run: sleep 30
- name: Publish hm-dsl-engine
run: |
if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-dsl-engine/$VERSION" > /dev/null 2>&1; then
echo "hm-dsl-engine@$VERSION already published, skipping"
else
cargo publish -p hm-dsl-engine --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty --no-verify
fi
- name: Wait for crates.io index
run: sleep 30
- name: Publish harmont-cli
run: |
if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/harmont-cli/$VERSION" > /dev/null 2>&1; then
echo "harmont-cli@$VERSION already published, skipping"
else
cargo publish -p harmont-cli --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty --no-verify
fi
build-binary:
name: Build ${{ matrix.target }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
- target: aarch64-unknown-linux-gnu
runner: ubuntu-24.04-arm
- target: aarch64-apple-darwin
runner: macos-latest
- target: x86_64-apple-darwin
runner: macos-latest
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: dsls/harmont-ts/package-lock.json
- name: Install esbuild
working-directory: dsls/harmont-ts
run: npm ci
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
sed -i'' -e 's/version = "0.0.0-dev"/version = "'"$VERSION"'"/' crates/hm/Cargo.toml
- name: Build
run: cargo build --release --target ${{ matrix.target }} -p harmont-cli
- name: Package
run: |
ARCHIVE="hm-${{ matrix.target }}.tar.gz"
tar czf "$ARCHIVE" -C "target/${{ matrix.target }}/release" hm
sha256sum "$ARCHIVE" > "$ARCHIVE.sha256" || shasum -a 256 "$ARCHIVE" > "$ARCHIVE.sha256"
- uses: actions/upload-artifact@v4
with:
name: hm-${{ matrix.target }}
path: |
hm-${{ matrix.target }}.tar.gz
hm-${{ matrix.target }}.tar.gz.sha256
retention-days: 1
github-release:
name: Create GitHub Release
timeout-minutes: 10
needs: build-binary
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create or update release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--clobber \
artifacts/*
else
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--title "$GITHUB_REF_NAME" \
--generate-notes \
artifacts/*
fi