1010 - main
1111 workflow_dispatch :
1212
13- permissions :
14- contents : write
15- packages : write
16-
1713jobs :
1814 check-version :
15+ permissions :
16+ contents : read
1917 if : github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
2018 runs-on : ubuntu-latest
2119 outputs :
@@ -24,22 +22,26 @@ jobs:
2422 should_run : ${{ steps.decide.outputs.should_run }}
2523 steps :
2624 - name : Checkout
27- uses : actions/checkout@v4
25+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2826 with :
2927 ref : ${{ github.event.workflow_run.head_sha || github.sha }}
28+ persist-credentials : false
3029
3130 - name : Read version
3231 id : version
32+ shell : bash
3333 run : |
3434 version=$(awk -F' *= *' '$1 == "version" { gsub(/"/, "", $2); print $2; exit }' Cargo.toml)
3535 echo "version=$version" >> "$GITHUB_OUTPUT"
3636
3737 - name : Check release existence
3838 id : release_check
39- uses : actions/github-script@v7
39+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
40+ env :
41+ VERSION : ${{ steps.version.outputs.version }}
4042 with :
4143 script : |
42- const tag = `${{ steps.version.outputs.version }}` ;
44+ const tag = process.env.VERSION ;
4345 try {
4446 await github.rest.repos.getReleaseByTag({
4547 owner: context.repo.owner,
@@ -57,28 +59,35 @@ jobs:
5759
5860 - name : Decide run
5961 id : decide
62+ shell : bash
63+ env :
64+ RELEASE_EXISTS : ${{ steps.release_check.outputs.release_exists }}
6065 run : |
61- if [[ "${{ steps.release_check.outputs.release_exists }} " == "false" ]]; then
66+ if [[ "$RELEASE_EXISTS " == "false" ]]; then
6267 echo "should_run=true" >> "$GITHUB_OUTPUT"
6368 else
6469 echo "should_run=false" >> "$GITHUB_OUTPUT"
6570 fi
6671
6772 build-database :
73+ permissions :
74+ contents : read
6875 runs-on : ubuntu-latest
6976 needs : check-version
7077 if : needs.check-version.outputs.should_run == 'true'
7178 steps :
7279 - name : Checkout
73- uses : actions/checkout@v4
80+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7481 with :
7582 ref : ${{ github.event.workflow_run.head_sha || github.sha }}
83+ persist-credentials : false
7684
77- - name : Set up Rust
78- uses : dtolnay/rust-toolchain@stable
85+ - name : Setup Rust
86+ shell : bash
87+ run : rustup update stable && rustup default stable
7988
8089 - name : Cache cargo
81- uses : actions/cache@v4
90+ uses : actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
8291 with :
8392 path : |
8493 ~/.cargo/registry
@@ -87,33 +96,37 @@ jobs:
8796 key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
8897
8998 - name : Create data directory
99+ shell : bash
90100 run : mkdir -p data
91101
92102 - name : Restore bag.bin cache
93103 id : bag_cache
94- uses : actions/cache/restore@v4
104+ uses : actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
95105 with :
96106 path : data/bag.bin
97107 key : bag-bin-${{ needs.check-version.outputs.version }}
98108
99109 - name : Create bag.bin
100110 if : steps.bag_cache.outputs.cache-hit != 'true'
111+ shell : bash
101112 run : cargo run --release --bin create-db --features "create"
102113
103114 - name : Save bag.bin cache
104115 if : steps.bag_cache.outputs.cache-hit != 'true'
105- uses : actions/cache/save@v4
116+ uses : actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
106117 with :
107118 path : data/bag.bin
108119 key : bag-bin-${{ needs.check-version.outputs.version }}
109120
110121 - name : Upload bag.bin
111- uses : actions/upload-artifact@v4
122+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
112123 with :
113124 name : bag.bin
114125 path : data/bag.bin
115126
116127 build :
128+ permissions :
129+ contents : read
117130 needs : [ check-version, build-database ]
118131 if : needs.check-version.outputs.should_run == 'true'
119132 runs-on : ${{ matrix.os }}
@@ -135,66 +148,77 @@ jobs:
135148 artifact : bag-service-macos-arm64
136149 steps :
137150 - name : Checkout
138- uses : actions/checkout@v4
151+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
139152 with :
140153 ref : ${{ github.event.workflow_run.head_sha || github.sha }}
154+ persist-credentials : false
141155
142156 - name : Download bag.bin
143- uses : actions/download-artifact@v4
157+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
144158 with :
145159 name : bag.bin
146160 path : data
147161
148- - name : Set up Rust
149- uses : dtolnay/rust-toolchain@stable
150- with :
151- targets : ${{ matrix.target }}
162+ - name : Setup Rust
163+ shell : bash
164+ run : >
165+ rustup update stable &&
166+ rustup default stable &&
167+ rustup target add --toolchain stable ${{ matrix.target }}
152168
153169 - name : Optionally install musl-tools
154170 if : matrix.target == 'x86_64-unknown-linux-musl' || matrix.target == 'arm64-unknown-linux-musl'
171+ shell : bash
155172 run : sudo apt-get install -y musl-tools
156173
157- - uses : Swatinem/rust-cache@v2
174+ - uses : Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
158175
159176 - name : Build
177+ shell : bash
160178 env :
161179 CC_aarch64_unknown_linux_musl : ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'musl-gcc' || '' }}
162180 run : cargo build --release --bin bag-service --target ${{ matrix.target }}
163181
164182 - name : Package
183+ shell : bash
165184 run : |
166185 mkdir -p dist
167186 cp target/${{ matrix.target }}/release/bag-service dist/${{ matrix.artifact }}
168187
169188 - name : Upload artifact
170- uses : actions/upload-artifact@v4
189+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
171190 with :
172191 name : ${{ matrix.artifact }}
173192 path : dist/${{ matrix.artifact }}
174193
175194 docker :
195+ permissions :
196+ contents : read
197+ packages : write
176198 needs :
177199 - check-version
178200 - build
179201 if : needs.check-version.outputs.should_run == 'true'
180202 runs-on : ubuntu-latest
181203 steps :
182- - uses : actions/checkout@v6
204+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
205+ with :
206+ persist-credentials : false
183207 - name : Download linux x64 artifact
184- uses : actions/download-artifact@v4
208+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
185209 with :
186210 name : bag-service-linux-x64
187211 path : dist
188212
189213 - name : Login to GitHub Container Registry
190- uses : docker/login-action@v3
214+ uses : docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
191215 with :
192216 registry : ghcr.io
193217 username : ${{ github.actor }}
194218 password : ${{ secrets.GITHUB_TOKEN }}
195219
196220 - name : Build and push docker image
197- uses : docker/build-push-action@v6
221+ uses : docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
198222 with :
199223 file : Dockerfile
200224 push : true
@@ -203,44 +227,49 @@ jobs:
203227 tags : " ghcr.io/tweedegolf/bag-address-lookup:${{ needs.check-version.outputs.version }},ghcr.io/tweedegolf/bag-address-lookup:latest"
204228
205229 release :
230+ permissions :
231+ contents : write
206232 needs :
207233 - check-version
208234 - build
209235 if : needs.check-version.outputs.should_run == 'true'
210236 runs-on : ubuntu-latest
211237 steps :
212238 - name : Download linux x64 artifact
213- uses : actions/download-artifact@v4
239+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
214240 with :
215241 name : bag-service-linux-x64
216242 path : dist
217243
218244 - name : Download linux arm64 artifact
219- uses : actions/download-artifact@v4
245+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
220246 with :
221247 name : bag-service-linux-arm64
222248 path : dist
223249
224250 - name : Download macos x64 artifact
225- uses : actions/download-artifact@v4
251+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
226252 with :
227253 name : bag-service-macos-x64
228254 path : dist
229255
230256 - name : Download macos arm64 artifact
231- uses : actions/download-artifact@v4
257+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
232258 with :
233259 name : bag-service-macos-arm64
234260 path : dist
235261
236262 - name : Create release
237- uses : softprops/action-gh-release@v2
238- with :
239- tag_name : ${{ needs.check-version.outputs.version }}
240- name : Version ${{ needs.check-version.outputs.version }}
241- generate_release_notes : true
242- files : |
243- dist/bag-service-linux-x64
244- dist/bag-service-linux-arm64
245- dist/bag-service-macos-x64
263+ shell : bash
264+ env :
265+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
266+ VERSION : ${{ needs.check-version.outputs.version }}
267+ GH_REPO : ${{ github.repository }}
268+ run : |
269+ gh release create "$VERSION" \
270+ --title "Version $VERSION" \
271+ --generate-notes \
272+ dist/bag-service-linux-x64 \
273+ dist/bag-service-linux-arm64 \
274+ dist/bag-service-macos-x64 \
246275 dist/bag-service-macos-arm64
0 commit comments