1+ # Copyright 2022-2023, axodotdev
2+ # SPDX-License-Identifier: MIT or Apache-2.0
3+ #
14# CI that:
25#
36# * checks for a Git Tag that looks like a release
4- # * creates a Github Release™ and fills in its text
5- # * builds artifacts with cargo-dist (executable-zips, installers)
7+ # * creates a draft Github Release™ and fills in its text
8+ # * builds artifacts with cargo-dist (executable-zips, installers, hashes )
69# * uploads those artifacts to the Github Release™
10+ # * undrafts the Github Release™ on success
711#
812# Note that the Github Release™ will be created before the artifacts,
913# so there will be a few minutes where the release has no artifacts
@@ -18,44 +22,50 @@ permissions:
1822 contents : write
1923
2024# This task will run whenever you push a git tag that looks like a version
21- # like "v1", "v1.2 .0", "v0.1.0-prerelease01 ", "my-app- v1.0.0", etc.
22- # The version will be roughly parsed as ({PACKAGE_NAME}-)?v{ VERSION} , where
25+ # like "1.0 .0", "v0.1.0-prerelease.1 ", "my-app/0.1.0", "releases/ v1.0.0", etc.
26+ # Various formats will be parsed into a VERSION and an optional PACKAGE_NAME , where
2327# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
24- # must be a Cargo-style SemVer Version.
28+ # must be a Cargo-style SemVer Version (must have at least major.minor.patch) .
2529#
26- # If PACKAGE_NAME is specified, then we will create a Github Release™ for that
30+ # If PACKAGE_NAME is specified, then the release will be for that
2731# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
2832#
29- # If PACKAGE_NAME isn't specified, then we will create a Github Release™ for all
30- # (cargo-dist-able) packages in the workspace with that version (this is mode is
33+ # If PACKAGE_NAME isn't specified, then the release will be for all
34+ # (cargo-dist-able) packages in the workspace with that version (this mode is
3135# intended for workspaces with only one dist-able package, or with all dist-able
3236# packages versioned/released in lockstep).
3337#
3438# If you push multiple tags at once, separate instances of this workflow will
35- # spin up, creating an independent Github Release™ for each one.
39+ # spin up, creating an independent Github Release™ for each one. However Github
40+ # will hard limit this to 3 tags per commit, as it will assume more tags is a
41+ # mistake.
3642#
37- # If there's a prerelease-style suffix to the version then the Github Release™
43+ # If there's a prerelease-style suffix to the version, then the Github Release™
3844# will be marked as a prerelease.
3945on :
4046 push :
4147 tags :
42- - ' *-?v [0-9]+*'
48+ - ' **[0-9]+.[0-9]+. [0-9]+*'
4349
4450jobs :
45- # Create the Github Release™ so the packages have something to be uploaded to
46- create-release :
51+ # Run 'cargo dist plan' to determine what tasks we need to do
52+ # and create a draft github release with the computed title/body
53+ plan :
4754 runs-on : ubuntu-latest
4855 outputs :
49- has-releases : ${{ steps.create-release.outputs.has-releases }}
56+ has-releases : ${{ steps.plan.outputs.has-releases }}
57+ releases : ${{ steps.plan.outputs.releases }}
5058 env :
5159 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5260 steps :
5361 - uses : actions/checkout@v3
62+ with :
63+ submodules : recursive
5464 - name : Install Rust
55- run : rustup update 1.67.1 --no-self-update && rustup default 1.67.1
65+ run : rustup update "1.70.0" --no-self-update && rustup default "1.70.0"
5666 - name : Install cargo-dist
57- run : curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7 /cargo-dist-installer.sh | sh
58- - id : create-release
67+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0 /cargo-dist-installer.sh | sh"
68+ - id : plan
5969 run : |
6070 cargo dist plan --tag=${{ github.ref_name }} --output-format=json > dist-manifest.json
6171 echo "dist plan ran successfully"
@@ -75,33 +85,39 @@ jobs:
7585 # Disable all the upload-artifacts tasks if we have no actual releases
7686 HAS_RELEASES=$(jq --raw-output ".releases != null" dist-manifest.json)
7787 echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT"
88+ echo "releases=$(jq --compact-output ".releases" dist-manifest.json)" >> "$GITHUB_OUTPUT"
7889
79- # Build and packages all the things
80- upload-artifacts :
90+ # Build and packages all the platform-specific things
91+ upload-local- artifacts :
8192 # Let the initial task tell us to not run (currently very blunt)
82- needs : create-release
83- if : ${{ needs.create-release .outputs.has-releases == 'true' }}
93+ needs : plan
94+ if : ${{ needs.plan .outputs.has-releases == 'true' }}
8495 strategy :
96+ fail-fast : false
8597 matrix :
8698 # For these target platforms
8799 include :
88- - os : macos-11
89- dist-args : --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin
90- install-dist : curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
91- - os : ubuntu-20.04
92- dist-args : --artifacts=local --target=x86_64-unknown-linux-gnu
93- install-dist : curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
94- - os : windows-2019
95- dist-args : --artifacts=local --target=x86_64-pc-windows-msvc
96- install-dist : irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.ps1 | iex
97-
100+ - os : " macos-11"
101+ dist-args : " --artifacts=local --target=aarch64-apple-darwin"
102+ install-dist : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh"
103+ - os : " macos-11"
104+ dist-args : " --artifacts=local --target=x86_64-apple-darwin"
105+ install-dist : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh"
106+ - os : " windows-2019"
107+ dist-args : " --artifacts=local --target=x86_64-pc-windows-msvc"
108+ install-dist : " irm https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.ps1 | iex"
109+ - os : " ubuntu-20.04"
110+ dist-args : " --artifacts=local --target=x86_64-unknown-linux-gnu"
111+ install-dist : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh"
98112 runs-on : ${{ matrix.os }}
99113 env :
100114 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
101115 steps :
102116 - uses : actions/checkout@v3
117+ with :
118+ submodules : recursive
103119 - name : Install Rust
104- run : rustup update 1.67.1 --no-self-update && rustup default 1.67.1
120+ run : rustup update "1.70.0" --no-self-update && rustup default "1.70.0"
105121 - name : Install cargo-dist
106122 run : ${{ matrix.install-dist }}
107123 - name : Run cargo-dist
@@ -122,16 +138,49 @@ jobs:
122138 gh release upload ${{ github.ref_name }} $(cat uploads.txt)
123139 echo "uploaded!"
124140
141+ # Build and package all the platform-agnostic(ish) things
142+ upload-global-artifacts :
143+ needs : upload-local-artifacts
144+ runs-on : " ubuntu-20.04"
145+ env :
146+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
147+ steps :
148+ - uses : actions/checkout@v3
149+ with :
150+ submodules : recursive
151+ - name : Install Rust
152+ run : rustup update "1.70.0" --no-self-update && rustup default "1.70.0"
153+ - name : Install cargo-dist
154+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh"
155+ # Get all the local artifacts for the global tasks to use (for e.g. checksums)
156+ - name : Fetch local artifacts
157+ run : |
158+ gh release download ${{ github.ref_name }} --dir target/distrib/
159+ - name : Run cargo-dist
160+ run : |
161+ cargo dist build --tag=${{ github.ref_name }} --output-format=json "--artifacts=global" > dist-manifest.json
162+ echo "dist ran successfully"
163+ cat dist-manifest.json
164+
165+ # Parse out what we just built and upload it to the Github Release™
166+ jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json > uploads.txt
167+ echo "uploading..."
168+ cat uploads.txt
169+ gh release upload ${{ github.ref_name }} $(cat uploads.txt)
170+ echo "uploaded!"
171+
125172 # Mark the Github Release™ as a non-draft now that everything has succeeded!
126173 publish-release :
127174 # Only run after all the other tasks, but it's ok if upload-artifacts was skipped
128- needs : [create-release , upload-artifacts]
129- if : ${{ always() && needs.create-release .result == 'success' && (needs.upload-artifacts.result == 'skipped' || needs.upload-artifacts.result == 'success') }}
175+ needs : [plan, upload-local-artifacts , upload-global -artifacts]
176+ if : ${{ always() && needs.plan.result == 'success' && (needs.upload-local-artifacts .result == 'skipped' || needs.upload-local-artifacts.result == ' success') && (needs.upload-global- artifacts.result == 'skipped' || needs.upload-global -artifacts.result == 'success') }}
130177 runs-on : ubuntu-latest
131178 env :
132179 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
133180 steps :
134181 - uses : actions/checkout@v3
182+ with :
183+ submodules : recursive
135184 - name : mark release as non-draft
136185 run : |
137186 gh release edit ${{ github.ref_name }} --draft=false
0 commit comments