Skip to content

Commit 0489050

Browse files
authored
release: v0.3.0, plus settings up release pipeline and docs (#17)
1 parent 6af328b commit 0489050

File tree

9 files changed

+209
-6
lines changed

9 files changed

+209
-6
lines changed

.github/workflows/release.yml

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Copyright 2022-2023, 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+
name: Release
14+
15+
permissions:
16+
contents: write
17+
18+
# This task will run whenever you push a git tag that looks like a version
19+
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
20+
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
21+
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
22+
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
23+
#
24+
# If PACKAGE_NAME is specified, then the release will be for that
25+
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
26+
#
27+
# If PACKAGE_NAME isn't specified, then the release will be for all
28+
# (cargo-dist-able) packages in the workspace with that version (this mode is
29+
# intended for workspaces with only one dist-able package, or with all dist-able
30+
# packages versioned/released in lockstep).
31+
#
32+
# If you push multiple tags at once, separate instances of this workflow will
33+
# spin up, creating an independent Github Release™ for each one. However Github
34+
# will hard limit this to 3 tags per commit, as it will assume more tags is a
35+
# mistake.
36+
#
37+
# If there's a prerelease-style suffix to the version, then the Github Release™
38+
# will be marked as a prerelease.
39+
on:
40+
push:
41+
tags:
42+
- '**[0-9]+.[0-9]+.[0-9]+*'
43+
pull_request:
44+
45+
jobs:
46+
# Run 'cargo dist plan' to determine what tasks we need to do
47+
plan:
48+
runs-on: ubuntu-latest
49+
outputs:
50+
val: ${{ steps.plan.outputs.manifest }}
51+
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
52+
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
53+
publishing: ${{ !github.event.pull_request }}
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
submodules: recursive
60+
- name: Install cargo-dist
61+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.4.2/cargo-dist-installer.sh | sh"
62+
- id: plan
63+
run: |
64+
cargo dist plan ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} --output-format=json > dist-manifest.json
65+
echo "cargo dist plan ran successfully"
66+
cat dist-manifest.json
67+
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
68+
- name: "Upload dist-manifest.json"
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: artifacts
72+
path: dist-manifest.json
73+
74+
# Build and packages all the platform-specific things
75+
upload-local-artifacts:
76+
# Let the initial task tell us to not run (currently very blunt)
77+
needs: plan
78+
if: ${{ fromJson(needs.plan.outputs.val).releases != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
79+
strategy:
80+
fail-fast: false
81+
# Target platforms/runners are computed by cargo-dist in create-release.
82+
# Each member of the matrix has the following arguments:
83+
#
84+
# - runner: the github runner
85+
# - dist-args: cli flags to pass to cargo dist
86+
# - install-dist: expression to run to install cargo-dist on the runner
87+
#
88+
# Typically there will be:
89+
# - 1 "global" task that builds universal installers
90+
# - N "local" tasks that build each platform's binaries and platform-specific installers
91+
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
92+
runs-on: ${{ matrix.runner }}
93+
env:
94+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
96+
steps:
97+
- uses: actions/checkout@v4
98+
with:
99+
submodules: recursive
100+
- uses: swatinem/rust-cache@v2
101+
- name: Install cargo-dist
102+
run: ${{ matrix.install_dist }}
103+
- name: Install dependencies
104+
run: |
105+
${{ matrix.packages_install }}
106+
- name: Build artifacts
107+
run: |
108+
# Actually do builds and make zips and whatnot
109+
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
110+
echo "cargo dist ran successfully"
111+
- id: cargo-dist
112+
name: Post-build
113+
# We force bash here just because github makes it really hard to get values up
114+
# to "real" actions without writing to env-vars, and writing to env-vars has
115+
# inconsistent syntax between shell and powershell.
116+
shell: bash
117+
run: |
118+
# Parse out what we just built and upload it to the Github Release™
119+
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
120+
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
121+
echo "EOF" >> "$GITHUB_OUTPUT"
122+
123+
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
124+
- name: "Upload artifacts"
125+
uses: actions/upload-artifact@v3
126+
with:
127+
name: artifacts
128+
path: |
129+
${{ steps.cargo-dist.outputs.paths }}
130+
${{ env.BUILD_MANIFEST_NAME }}
131+
132+
should-publish:
133+
needs:
134+
- plan
135+
- upload-local-artifacts
136+
if: ${{ needs.plan.outputs.publishing == 'true' }}
137+
runs-on: ubuntu-latest
138+
steps:
139+
- name: print tag
140+
run: echo "ok we're publishing!"
141+
142+
# Create a Github Release with all the results once everything is done
143+
publish-release:
144+
needs: [plan, should-publish]
145+
runs-on: ubuntu-latest
146+
env:
147+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
steps:
149+
- uses: actions/checkout@v4
150+
with:
151+
submodules: recursive
152+
- name: "Download artifacts"
153+
uses: actions/download-artifact@v3
154+
with:
155+
name: artifacts
156+
path: artifacts
157+
- name: Cleanup
158+
run: |
159+
# Remove the granular manifests
160+
rm artifacts/*-dist-manifest.json
161+
- name: Create Release
162+
uses: ncipollo/release-action@v1
163+
with:
164+
tag: ${{ needs.plan.outputs.tag }}
165+
name: ${{ fromJson(needs.plan.outputs.val).announcement_title }}
166+
body: ${{ fromJson(needs.plan.outputs.val).announcement_github_body }}
167+
prerelease: ${{ fromJson(needs.plan.outputs.val).announcement_is_prerelease }}
168+
artifacts: "artifacts/*"
File renamed without changes.

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+19
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,22 @@ members = [
55
"nomen",
66
"nomen-cli"
77
]
8+
9+
# Config for 'cargo dist'
10+
[workspace.metadata.dist]
11+
include = ["RELEASE_NOTES.md"]
12+
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
13+
cargo-dist-version = "0.4.2"
14+
# CI backends to support
15+
ci = ["github"]
16+
# The installers to generate for each app
17+
installers = []
18+
# Target platforms to build apps for (Rust target-triple syntax)
19+
targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-pc-windows-msvc"]
20+
# Publish jobs to run in CI
21+
pr-run-mode = "plan"
22+
23+
# The profile that 'cargo dist' will build with
24+
[profile.dist]
25+
inherits = "release"
26+
lto = "thin"
File renamed without changes.

docs/RELEASE.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Preparing A Release
2+
3+
1. Crate release branch.
4+
2. Archive current `CHANGELOG.md` to `docs/changelogs/vY.Y.Y.md`, replacing `Y.Y.Y` with the current version number.
5+
3. Archive current `RELEASE_NOTES.md` to `docs/release_notes/vY.Y.Y.md`, replacing `Y.Y.Y` with the current version number.
6+
4. Update version numbers in `Cargo.toml` files to new version.
7+
5. Run `git cliff -o CHANGELOG.md --unreleased --tag vX.X.X`, replacing `X.X.X` with the new version.
8+
6. Write new `RELEASE_NOTES.md`, containing highlights of the release, and special release instructions that must be done prior to upgrade.
9+
7. Commit with a `release:` tag on the commit message.
10+
8. Open PR to `master` and merge.
11+
9. `git tag vY.Y.Y && git push --tags` to create the release and build the artifacts.

nomen-cli/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[package]
22
name = "nomen-cli"
3-
version = "0.3.0-pre.4"
3+
version = "0.3.0"
44
edition = "2021"
5+
rust-version = "1.71"
6+
repository = "https://github.com/ursuscamp/nomen"
57

68
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
79

nomen/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[package]
22
name = "nomen"
3-
version = "0.3.0-pre.4"
3+
version = "0.3.0"
44
edition = "2021"
55
build = "build.rs"
66
default-run = "nomen"
7+
rust-version = "1.71"
8+
repository = "https://github.com/ursuscamp/nomen"
79

810
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
911

nomen_core/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[package]
22
name = "nomen_core"
3-
version = "0.3.0-pre.4"
3+
version = "0.3.0"
44
edition = "2021"
55
rust-version = "1.71"
6+
repository = "https://github.com/ursuscamp/nomen"
67

78
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
89

0 commit comments

Comments
 (0)