···11+# Copyright 2022-2024, axodotdev
22+# SPDX-License-Identifier: MIT or Apache-2.0
33+#
44+# CI that:
55+#
66+# * checks for a Git Tag that looks like a release
77+# * builds artifacts with cargo-dist (archives, installers, hashes)
88+# * uploads those artifacts to temporary workflow zip
99+# * on success, uploads the artifacts to a GitHub Release
1010+#
1111+# Note that the GitHub Release will be created with a generated
1212+# title/body based on your changelogs.
1313+1414+name: Release
1515+1616+permissions:
1717+ contents: write
1818+1919+# This task will run whenever you push a git tag that looks like a version
2020+# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
2121+# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
2222+# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
2323+# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2424+#
2525+# If PACKAGE_NAME is specified, then the announcement will be for that
2626+# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
2727+#
2828+# If PACKAGE_NAME isn't specified, then the announcement will be for all
2929+# (cargo-dist-able) packages in the workspace with that version (this mode is
3030+# intended for workspaces with only one dist-able package, or with all dist-able
3131+# packages versioned/released in lockstep).
3232+#
3333+# If you push multiple tags at once, separate instances of this workflow will
3434+# spin up, creating an independent announcement for each one. However, GitHub
3535+# will hard limit this to 3 tags per commit, as it will assume more tags is a
3636+# mistake.
3737+#
3838+# If there's a prerelease-style suffix to the version, then the release(s)
3939+# will be marked as a prerelease.
4040+on:
4141+ push:
4242+ tags:
4343+ - '**[0-9]+.[0-9]+.[0-9]+*'
4444+ pull_request:
4545+4646+jobs:
4747+ # Run 'cargo dist plan' (or host) to determine what tasks we need to do
4848+ plan:
4949+ runs-on: ubuntu-latest
5050+ outputs:
5151+ val: ${{ steps.plan.outputs.manifest }}
5252+ tag: ${{ !github.event.pull_request && github.ref_name || '' }}
5353+ tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
5454+ publishing: ${{ !github.event.pull_request }}
5555+ env:
5656+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757+ steps:
5858+ - uses: actions/checkout@v4
5959+ with:
6060+ submodules: recursive
6161+ - name: Install cargo-dist
6262+ # we specify bash to get pipefail; it guards against the `curl` command
6363+ # failing. otherwise `sh` won't catch that `curl` returned non-0
6464+ shell: bash
6565+ run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh"
6666+ # sure would be cool if github gave us proper conditionals...
6767+ # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
6868+ # functionality based on whether this is a pull_request, and whether it's from a fork.
6969+ # (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7070+ # but also really annoying to build CI around when it needs secrets to work right.)
7171+ - id: plan
7272+ run: |
7373+ cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
7474+ echo "cargo dist ran successfully"
7575+ cat plan-dist-manifest.json
7676+ echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
7777+ - name: "Upload dist-manifest.json"
7878+ uses: actions/upload-artifact@v4
7979+ with:
8080+ name: artifacts-plan-dist-manifest
8181+ path: plan-dist-manifest.json
8282+8383+ # Build and packages all the platform-specific things
8484+ build-local-artifacts:
8585+ name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
8686+ # Let the initial task tell us to not run (currently very blunt)
8787+ needs:
8888+ - plan
8989+ 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') }}
9090+ strategy:
9191+ fail-fast: false
9292+ # Target platforms/runners are computed by cargo-dist in create-release.
9393+ # Each member of the matrix has the following arguments:
9494+ #
9595+ # - runner: the github runner
9696+ # - dist-args: cli flags to pass to cargo dist
9797+ # - install-dist: expression to run to install cargo-dist on the runner
9898+ #
9999+ # Typically there will be:
100100+ # - 1 "global" task that builds universal installers
101101+ # - N "local" tasks that build each platform's binaries and platform-specific installers
102102+ matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
103103+ runs-on: ${{ matrix.runner }}
104104+ env:
105105+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106106+ BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107107+ steps:
108108+ - name: enable windows longpaths
109109+ run: |
110110+ git config --global core.longpaths true
111111+ - uses: actions/checkout@v4
112112+ with:
113113+ submodules: recursive
114114+ - uses: swatinem/rust-cache@v2
115115+ with:
116116+ key: ${{ join(matrix.targets, '-') }}
117117+ - name: Install cargo-dist
118118+ run: ${{ matrix.install_dist }}
119119+ # Get the dist-manifest
120120+ - name: Fetch local artifacts
121121+ uses: actions/download-artifact@v4
122122+ with:
123123+ pattern: artifacts-*
124124+ path: target/distrib/
125125+ merge-multiple: true
126126+ - name: Install dependencies
127127+ run: |
128128+ ${{ matrix.packages_install }}
129129+ - name: Build artifacts
130130+ run: |
131131+ # Actually do builds and make zips and whatnot
132132+ cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
133133+ echo "cargo dist ran successfully"
134134+ - id: cargo-dist
135135+ name: Post-build
136136+ # We force bash here just because github makes it really hard to get values up
137137+ # to "real" actions without writing to env-vars, and writing to env-vars has
138138+ # inconsistent syntax between shell and powershell.
139139+ shell: bash
140140+ run: |
141141+ # Parse out what we just built and upload it to scratch storage
142142+ echo "paths<<EOF" >> "$GITHUB_OUTPUT"
143143+ jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
144144+ echo "EOF" >> "$GITHUB_OUTPUT"
145145+146146+ cp dist-manifest.json "$BUILD_MANIFEST_NAME"
147147+ - name: "Upload artifacts"
148148+ uses: actions/upload-artifact@v4
149149+ with:
150150+ name: artifacts-build-local-${{ join(matrix.targets, '_') }}
151151+ path: |
152152+ ${{ steps.cargo-dist.outputs.paths }}
153153+ ${{ env.BUILD_MANIFEST_NAME }}
154154+155155+ # Build and package all the platform-agnostic(ish) things
156156+ build-global-artifacts:
157157+ needs:
158158+ - plan
159159+ - build-local-artifacts
160160+ runs-on: "ubuntu-20.04"
161161+ env:
162162+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163163+ BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
164164+ steps:
165165+ - uses: actions/checkout@v4
166166+ with:
167167+ submodules: recursive
168168+ - name: Install cargo-dist
169169+ shell: bash
170170+ run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh"
171171+ # Get all the local artifacts for the global tasks to use (for e.g. checksums)
172172+ - name: Fetch local artifacts
173173+ uses: actions/download-artifact@v4
174174+ with:
175175+ pattern: artifacts-*
176176+ path: target/distrib/
177177+ merge-multiple: true
178178+ - id: cargo-dist
179179+ shell: bash
180180+ run: |
181181+ cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
182182+ echo "cargo dist ran successfully"
183183+184184+ # Parse out what we just built and upload it to scratch storage
185185+ echo "paths<<EOF" >> "$GITHUB_OUTPUT"
186186+ jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
187187+ echo "EOF" >> "$GITHUB_OUTPUT"
188188+189189+ cp dist-manifest.json "$BUILD_MANIFEST_NAME"
190190+ - name: "Upload artifacts"
191191+ uses: actions/upload-artifact@v4
192192+ with:
193193+ name: artifacts-build-global
194194+ path: |
195195+ ${{ steps.cargo-dist.outputs.paths }}
196196+ ${{ env.BUILD_MANIFEST_NAME }}
197197+ # Determines if we should publish/announce
198198+ host:
199199+ needs:
200200+ - plan
201201+ - build-local-artifacts
202202+ - build-global-artifacts
203203+ # Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
204204+ 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') }}
205205+ env:
206206+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
207207+ runs-on: "ubuntu-20.04"
208208+ outputs:
209209+ val: ${{ steps.host.outputs.manifest }}
210210+ steps:
211211+ - uses: actions/checkout@v4
212212+ with:
213213+ submodules: recursive
214214+ - name: Install cargo-dist
215215+ run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh"
216216+ # Fetch artifacts from scratch-storage
217217+ - name: Fetch artifacts
218218+ uses: actions/download-artifact@v4
219219+ with:
220220+ pattern: artifacts-*
221221+ path: target/distrib/
222222+ merge-multiple: true
223223+ # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
224224+ - id: host
225225+ shell: bash
226226+ run: |
227227+ cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
228228+ echo "artifacts uploaded and released successfully"
229229+ cat dist-manifest.json
230230+ echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
231231+ - name: "Upload dist-manifest.json"
232232+ uses: actions/upload-artifact@v4
233233+ with:
234234+ # Overwrite the previous copy
235235+ name: artifacts-dist-manifest
236236+ path: dist-manifest.json
237237+238238+ # Create a GitHub Release while uploading all files to it
239239+ announce:
240240+ needs:
241241+ - plan
242242+ - host
243243+ # use "always() && ..." to allow us to wait for all publish jobs while
244244+ # still allowing individual publish jobs to skip themselves (for prereleases).
245245+ # "host" however must run to completion, no skipping allowed!
246246+ if: ${{ always() && needs.host.result == 'success' }}
247247+ runs-on: "ubuntu-20.04"
248248+ env:
249249+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250250+ steps:
251251+ - uses: actions/checkout@v4
252252+ with:
253253+ submodules: recursive
254254+ - name: "Download GitHub Artifacts"
255255+ uses: actions/download-artifact@v4
256256+ with:
257257+ pattern: artifacts-*
258258+ path: artifacts
259259+ merge-multiple: true
260260+ - name: Cleanup
261261+ run: |
262262+ # Remove the granular manifests
263263+ rm -f artifacts/*-dist-manifest.json
264264+ - name: Create GitHub Release
265265+ uses: ncipollo/release-action@v1
266266+ with:
267267+ tag: ${{ needs.plan.outputs.tag }}
268268+ name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
269269+ body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
270270+ prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
271271+ artifacts: "artifacts/*"
+21-1
Cargo.toml
···55license = "MIT OR Apache-2.0"
66repository = "https://github.com/urschrei/cvmcount"
7788-version = "0.1.1"
88+version = "0.1.2"
99edition = "2021"
10101111[dependencies]
···3030[profile.bench]
3131lto = true
3232codegen-units = 1
3333+3434+# The profile that 'cargo dist' will build with
3535+[profile.dist]
3636+inherits = "release"
3737+lto = "thin"
3838+3939+# Config for 'cargo dist'
4040+[workspace.metadata.dist]
4141+# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
4242+cargo-dist-version = "0.13.3"
4343+# CI backends to support
4444+ci = ["github"]
4545+# The installers to generate for each app
4646+installers = ["shell"]
4747+# Target platforms to build apps for (Rust target-triple syntax)
4848+targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
4949+# Publish jobs to run in CI
5050+pr-run-mode = "plan"
5151+# Whether to install an updater program
5252+install-updater = false