Skip to content

Commit 09e9bb7

Browse files
Merge pull request #1 from RandyMcMillan/2010/857395/655548/50a3c43/697a075-blocks-mostly-done
2010/857395/655548/50a3c43/697a075 blocks mostly done
2 parents 7b78c8a + 697a075 commit 09e9bb7

File tree

116 files changed

+8527
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+8527
-129
lines changed

.github/workflows/release.yml

Lines changed: 312 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,312 @@
1+
# Copyright 2022-2024, axodotdev
2+
# SPDX-License-Identifier: MIT or Apache-2.0
3+
#
4+
# CI that:
5+
#
6+
# * checks for a Git Tag that looks like a release
7+
# * builds artifacts with cargo-dist (archives, installers, hashes)
8+
# * uploads those artifacts to temporary workflow zip
9+
# * on success, uploads the artifacts to a GitHub Release
10+
#
11+
# Note that the GitHub Release will be created with a generated
12+
# title/body based on your changelogs.
13+
14+
name: Release
15+
16+
permissions:
17+
contents: write
18+
19+
# This task will run whenever you push a git tag that looks like a version
20+
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
21+
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
22+
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
23+
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
24+
#
25+
# If PACKAGE_NAME is specified, then the announcement will be for that
26+
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
27+
#
28+
# If PACKAGE_NAME isn't specified, then the announcement will be for all
29+
# (cargo-dist-able) packages in the workspace with that version (this mode is
30+
# intended for workspaces with only one dist-able package, or with all dist-able
31+
# packages versioned/released in lockstep).
32+
#
33+
# If you push multiple tags at once, separate instances of this workflow will
34+
# spin up, creating an independent announcement for each one. However, GitHub
35+
# will hard limit this to 3 tags per commit, as it will assume more tags is a
36+
# mistake.
37+
#
38+
# If there's a prerelease-style suffix to the version, then the release(s)
39+
# will be marked as a prerelease.
40+
on:
41+
push:
42+
tags:
43+
- '**[0-9]+.[0-9]+.[0-9]+*'
44+
pull_request:
45+
46+
jobs:
47+
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
48+
plan:
49+
runs-on: ubuntu-latest
50+
outputs:
51+
val: ${{ steps.plan.outputs.manifest }}
52+
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
53+
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
54+
publishing: ${{ !github.event.pull_request }}
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
submodules: recursive
61+
- name: Install cargo-dist
62+
# we specify bash to get pipefail; it guards against the `curl` command
63+
# failing. otherwise `sh` won't catch that `curl` returned non-0
64+
shell: bash
65+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
66+
# sure would be cool if github gave us proper conditionals...
67+
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
68+
# functionality based on whether this is a pull_request, and whether it's from a fork.
69+
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
70+
# but also really annoying to build CI around when it needs secrets to work right.)
71+
- id: plan
72+
run: |
73+
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
74+
echo "cargo dist ran successfully"
75+
cat plan-dist-manifest.json
76+
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
77+
- name: "Upload dist-manifest.json"
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: artifacts-plan-dist-manifest
81+
path: plan-dist-manifest.json
82+
83+
# Build and packages all the platform-specific things
84+
build-local-artifacts:
85+
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
86+
# Let the initial task tell us to not run (currently very blunt)
87+
needs:
88+
- plan
89+
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
90+
strategy:
91+
fail-fast: false
92+
# Target platforms/runners are computed by cargo-dist in create-release.
93+
# Each member of the matrix has the following arguments:
94+
#
95+
# - runner: the github runner
96+
# - dist-args: cli flags to pass to cargo dist
97+
# - install-dist: expression to run to install cargo-dist on the runner
98+
#
99+
# Typically there will be:
100+
# - 1 "global" task that builds universal installers
101+
# - N "local" tasks that build each platform's binaries and platform-specific installers
102+
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
103+
runs-on: ${{ matrix.runner }}
104+
env:
105+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107+
steps:
108+
- name: enable windows longpaths
109+
run: |
110+
git config --global core.longpaths true
111+
- uses: actions/checkout@v4
112+
with:
113+
submodules: recursive
114+
- uses: swatinem/rust-cache@v2
115+
with:
116+
key: ${{ join(matrix.targets, '-') }}
117+
- name: Install cargo-dist
118+
run: ${{ matrix.install_dist }}
119+
# Get the dist-manifest
120+
- name: Fetch local artifacts
121+
uses: actions/download-artifact@v4
122+
with:
123+
pattern: artifacts-*
124+
path: target/distrib/
125+
merge-multiple: true
126+
- name: Install dependencies
127+
run: |
128+
${{ matrix.packages_install }}
129+
- name: Build artifacts
130+
run: |
131+
# Actually do builds and make zips and whatnot
132+
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
133+
echo "cargo dist ran successfully"
134+
- id: cargo-dist
135+
name: Post-build
136+
# We force bash here just because github makes it really hard to get values up
137+
# to "real" actions without writing to env-vars, and writing to env-vars has
138+
# inconsistent syntax between shell and powershell.
139+
shell: bash
140+
run: |
141+
# Parse out what we just built and upload it to scratch storage
142+
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
143+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
144+
echo "EOF" >> "$GITHUB_OUTPUT"
145+
146+
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
147+
- name: "Upload artifacts"
148+
uses: actions/upload-artifact@v4
149+
with:
150+
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
151+
path: |
152+
${{ steps.cargo-dist.outputs.paths }}
153+
${{ env.BUILD_MANIFEST_NAME }}
154+
155+
# Build and package all the platform-agnostic(ish) things
156+
build-global-artifacts:
157+
needs:
158+
- plan
159+
- build-local-artifacts
160+
runs-on: "ubuntu-20.04"
161+
env:
162+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
164+
steps:
165+
- uses: actions/checkout@v4
166+
with:
167+
submodules: recursive
168+
- name: Install cargo-dist
169+
shell: bash
170+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
171+
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
172+
- name: Fetch local artifacts
173+
uses: actions/download-artifact@v4
174+
with:
175+
pattern: artifacts-*
176+
path: target/distrib/
177+
merge-multiple: true
178+
- id: cargo-dist
179+
shell: bash
180+
run: |
181+
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
182+
echo "cargo dist ran successfully"
183+
184+
# Parse out what we just built and upload it to scratch storage
185+
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
186+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
187+
echo "EOF" >> "$GITHUB_OUTPUT"
188+
189+
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
190+
- name: "Upload artifacts"
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: artifacts-build-global
194+
path: |
195+
${{ steps.cargo-dist.outputs.paths }}
196+
${{ env.BUILD_MANIFEST_NAME }}
197+
# Determines if we should publish/announce
198+
host:
199+
needs:
200+
- plan
201+
- build-local-artifacts
202+
- build-global-artifacts
203+
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
204+
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
205+
env:
206+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
207+
runs-on: "ubuntu-20.04"
208+
outputs:
209+
val: ${{ steps.host.outputs.manifest }}
210+
steps:
211+
- uses: actions/checkout@v4
212+
with:
213+
submodules: recursive
214+
- name: Install cargo-dist
215+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
216+
# Fetch artifacts from scratch-storage
217+
- name: Fetch artifacts
218+
uses: actions/download-artifact@v4
219+
with:
220+
pattern: artifacts-*
221+
path: target/distrib/
222+
merge-multiple: true
223+
# This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
224+
- id: host
225+
shell: bash
226+
run: |
227+
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
228+
echo "artifacts uploaded and released successfully"
229+
cat dist-manifest.json
230+
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
231+
- name: "Upload dist-manifest.json"
232+
uses: actions/upload-artifact@v4
233+
with:
234+
# Overwrite the previous copy
235+
name: artifacts-dist-manifest
236+
path: dist-manifest.json
237+
238+
publish-homebrew-formula:
239+
needs:
240+
- plan
241+
- host
242+
runs-on: "ubuntu-20.04"
243+
env:
244+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
245+
PLAN: ${{ needs.plan.outputs.val }}
246+
GITHUB_USER: "axo bot"
247+
GITHUB_EMAIL: "[email protected]"
248+
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
249+
steps:
250+
- uses: actions/checkout@v4
251+
with:
252+
repository: "randymcmillan/homebrew-randymcmillan"
253+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
254+
# So we have access to the formula
255+
- name: Fetch homebrew formulae
256+
uses: actions/download-artifact@v4
257+
with:
258+
pattern: artifacts-*
259+
path: Formula/
260+
merge-multiple: true
261+
# This is extra complex because you can make your Formula name not match your app name
262+
# so we need to find releases with a *.rb file, and publish with that filename.
263+
- name: Commit formula files
264+
run: |
265+
git config --global user.name "${GITHUB_USER}"
266+
git config --global user.email "${GITHUB_EMAIL}"
267+
268+
for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
269+
filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
270+
name=$(echo "$filename" | sed "s/\.rb$//")
271+
version=$(echo "$release" | jq .app_version --raw-output)
272+
273+
git add "Formula/${filename}"
274+
git commit -m "${name} ${version}"
275+
done
276+
git push
277+
278+
# Create a GitHub Release while uploading all files to it
279+
announce:
280+
needs:
281+
- plan
282+
- host
283+
- publish-homebrew-formula
284+
# use "always() && ..." to allow us to wait for all publish jobs while
285+
# still allowing individual publish jobs to skip themselves (for prereleases).
286+
# "host" however must run to completion, no skipping allowed!
287+
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
288+
runs-on: "ubuntu-20.04"
289+
env:
290+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
291+
steps:
292+
- uses: actions/checkout@v4
293+
with:
294+
submodules: recursive
295+
- name: "Download GitHub Artifacts"
296+
uses: actions/download-artifact@v4
297+
with:
298+
pattern: artifacts-*
299+
path: artifacts
300+
merge-multiple: true
301+
- name: Cleanup
302+
run: |
303+
# Remove the granular manifests
304+
rm -f artifacts/*-dist-manifest.json
305+
- name: Create GitHub Release
306+
uses: ncipollo/release-action@v1
307+
with:
308+
tag: ${{ needs.plan.outputs.tag }}
309+
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
310+
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
311+
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
312+
artifacts: "artifacts/*"

.github/workflows/rust.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "ma**" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build
20+
run: cargo build --verbose
21+
- name: Install
22+
run: cargo install --path . --verbose
23+
- name: Run tests
24+
run: cargo test -- --nocapture

.gitmodule

Whitespace-only changes.

.gitmodules

Whitespace-only changes.

0 commit comments

Comments
 (0)