Skip to content

Commit

Permalink
add publish to crates.io workflow
Browse files Browse the repository at this point in the history
- any commit on main will trigger a publish
- add developer release instructions

Signed-off-by: mimir-d <[email protected]>
  • Loading branch information
mimir-d committed Oct 14, 2024
1 parent bd24a98 commit 3427393
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: publish

on:
push:
branches: [main]

# only read-only for GITHUB_TOKEN
permissions:
contents: read

jobs:
publish_audit:
name: audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rustsec/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

publish_test:
name: test on ${{ matrix.os }} / stable
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo test --locked
run: cargo test --locked --all-features

publish:
name: publish to crates.io
needs:
- publish_audit
- publish_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: release
- name: cargo login
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish
run: |-
cargo release \
publish \
--all-features \
--allow-branch HEAD \
--no-confirm \
--execute
33 changes: 32 additions & 1 deletion DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,35 @@
assert_eq!(x, 42);
Ok(())
}
```
```

### Release process

To make a new release, and publish to crates.io, a new tagged commit needs to exist on the `main` branch. This is done with a simple merge from the `dev` branch. **Do not** push any other kinds of commits to the `main` branch.

Steps:
1. bump the version. Will need [`cargo-release`](https://crates.io/crates/cargo-release) crate. Example here bumps the *patch* version.
```bash
$ git checkout dev
$ cargo release version patch --execute
$ cargo release changes # note any changelog to add to the commit, or manually craft it
$ git add .
$ git commit
$ git push origin dev
```
2. merge `dev` into `main`
```bash
$ git checkout main
$ git merge --no-ff dev
```
3. tag the merge commit
```bash
$ git checkout main
$ cargo release tag --sign-tag --execute
```
4. push with tags
```bash
$ git checkout main
$ git push
$ git push --tags
```

0 comments on commit 3427393

Please sign in to comment.