Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish

# House scheme: a version bump on the default branch is the release. No tags,
# no manual step. Publishing is irreversible, so the trigger has to be
# something you cannot do by accident, and editing the version field is that.
#
# This crate's default branch is `master`, unlike ps-st3's `main`. Match the
# repository rather than copying the sibling, or the workflow silently never
# runs and the release looks like it worked.
on:
push:
branches: [master]
paths: ['Cargo.toml']

jobs:
publish:
runs-on: ubicloud-standard-2
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: dtolnay/rust-toolchain@stable

- id: version
run: |
new=$(sed -nE '0,/^version = "(.*)"/s//\1/p' Cargo.toml)
old=$(git show HEAD^:Cargo.toml | sed -nE '0,/^version = "(.*)"/s//\1/p')
if [ "$new" = "$old" ]; then
echo "version unchanged at $new, nothing to publish"
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "version $old -> $new"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

# The gate runs on this commit too, but a release must not depend on job
# ordering, so it is re-run here rather than assumed.
- if: steps.version.outputs.changed == 'true'
run: cargo test --release

# `no_std` is the reason this crate exists, so a release that only builds
# with an operating system underneath it is not a release.
- if: steps.version.outputs.changed == 'true'
run: cargo check --no-default-features

- if: steps.version.outputs.changed == 'true'
run: cargo publish --token "$CARGO_REGISTRY_TOKEN"
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/target-*
/Cargo.lock
Loading