Skip to content

Commit ba8112e

Browse files
committed
Add CI job to publish on crates.io when a release is tagged
This uses `katyo/publish-crates@v1`, which checks which crates have had their versions bumped, and releases them on crates.io. While making sure to publish dependencies first before the crate that depends on them. This has apparently worked well in drm-rs. Since subcrates are versioned differently, when we discussed this earlier date-based tags names seemed best. So as @elinorbgr suggested, this goes with `release-YYYY-MM-DD` as the tagging scheme. (The CI job checks for tags prefixed with `release-`). I can't really think of anything better than that. So to release, we should be able to simply update the versions in `Cargo.toml` files, update the changelog files, and tag a release. The `publish-crates` action requires that all subcrates depends on the latest version of any other crate in the repository. And it requires that all crates with changes have a bumped version so they can be released. This seems a bit annoying if we wanted to just release a change to `wayland-backend`, for instance, but should help avoid mistakes. Manually dealing with the releases for all the crates here, without any automated checks, is error-prone. The action here does a `dry-run` for all CI runs (and uses `ignore-unpublished-changes` to not error if crates have changes without already having their versions bumped). But disables `dry-run` when a tag is pushed with the right format. A `CRATES_TOKEN` secret will need to be added to the repository for this to work.
1 parent b393a32 commit ba8112e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/ci.yml

+23
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- master
7+
tags:
8+
- 'release-[0-9]+-[0-9]+-[0-9]+'
79
pull_request:
810

911
jobs:
@@ -429,3 +431,24 @@ jobs:
429431
github_token: ${{ secrets.GITHUB_TOKEN }}
430432
publish_dir: ./target/doc
431433
force_orphan: true
434+
435+
publish:
436+
needs:
437+
- format
438+
- doc
439+
- check-minimal
440+
runs-on: ubuntu-22.04
441+
steps:
442+
- uses: actions/checkout@v3
443+
- name: Setup Rust
444+
uses: actions-rs/toolchain@v1
445+
with:
446+
toolchain: stable
447+
override: true
448+
- name: Publish crates
449+
uses: katyo/publish-crates@v1
450+
with:
451+
registry-token: ${{ secrets.CRATES_TOKEN }}
452+
args: --no-verify
453+
dry-run: ${{ !(github.repository == 'Smithay/wayland-rs' && startsWith(github.ref, 'refs/tags/release-')) }}
454+
ignore-unpublished-changes: ${{ !(github.repository == 'Smithay/wayland-rs' && startsWith(github.ref, 'refs/tags/release-')) }}

0 commit comments

Comments
 (0)