ci: release to crates.io and Codeberg through a release-plz pull request

This commit is contained in:
Willem Vanhulle committed 2026-10-25 12:03:40 +01:00
1 parent 3a61dc9279
commit 9fa6e26d52
4 files changed
+132 -4

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
when:
- repo: wvhulle/bootvine
event: [push, manual]
branch: main
depends_on:
- rust-and-flake-checks
clone:
- name: clone-with-history-and-tags
image: woodpeckerci/plugin-git
settings:
depth: 0
partial: false
tags: true
variables:
- &release_env
NIX_CONFIG: |
experimental-features = nix-command flakes
build-users-group =
accept-flake-config = true
GIT_AUTHOR_NAME: release-plz
GIT_AUTHOR_EMAIL: willemvanhulle@protonmail.com
GIT_COMMITTER_NAME: release-plz
GIT_COMMITTER_EMAIL: willemvanhulle@protonmail.com
CODEBERG_TOKEN:
from_secret: codeberg_token
CARGO_REGISTRY_TOKEN:
from_secret: cargo_registry_token
steps:
- name: publish-crate-and-tag-release
image: nixos/nix:latest
environment: *release_env
commands:
- git remote set-url origin "https://wvhulle:$${CODEBERG_TOKEN}@codeberg.org/$${CI_REPO}.git"
- git checkout -B main "$${CI_COMMIT_SHA}"
- nix run .#release-plz-release
- name: update-release-pr
image: nixos/nix:latest
environment: *release_env
commands:
- nix run .#release-plz-release-pr
+16
View File
@@ -36,6 +36,22 @@ pull requests. Builds on `main` are pushed to the `wvhulle` [Cachix](https://www
`nixConfig` in `flake.nix` offers as a substituter. The two VM checks need KVM,
which Codeberg's runners lack, so they only run locally.
## Releases
`.woodpecker/release-pr-and-publish.yaml` runs
[release-plz](https://release-plz.dev) after the checks pass on `main`. It
keeps a pull request labelled `release` open on Codeberg that bumps the version
in `Cargo.toml` and adds the new commits to `CHANGELOG.md`. Only `feat`, `fix`
and `perf` commits open one; a `!` or a `BREAKING CHANGE` footer bumps the
minor version while bootvine is below 1.0. Merging that pull request publishes
the crate to crates.io, tags the merge `v<version>` and creates a Codeberg
release with the changelog. Settings are in `release-plz.toml`.
The pipeline needs two Woodpecker secrets: `codeberg_token`, a Codeberg access
token with repository write access, and `cargo_registry_token`, a crates.io
token that may publish new crates and updates. Preview the next release
locally from the dev shell with `release-plz update`.
## Testing
| What | Command |
+35 -4
View File
@@ -36,12 +36,16 @@
inherit system;
overlays = [ (import rust-overlay) ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain (
p: p.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml
);
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
in
f {
inherit system pkgs craneLib;
inherit
system
pkgs
craneLib
rustToolchain
;
builds = import ./crane-builds.nix { inherit lib pkgs craneLib; };
}
);
@@ -75,9 +79,34 @@
pkgs,
system,
builds,
rustToolchain,
...
}:
let
runReleasePlzOnCodeberg = subcommand: description: {
type = "app";
meta.description = description;
program = lib.getExe (
pkgs.writeShellApplication {
name = "release-plz-${subcommand}";
runtimeInputs = [
pkgs.release-plz
pkgs.gitMinimal
pkgs.pkg-config
pkgs.stdenv.cc
rustToolchain
];
text = ''
export PKG_CONFIG_PATH="${lib.getDev pkgs.dbus}/lib/pkgconfig"
exec release-plz ${subcommand} --forge gitea --git-token "$CODEBERG_TOKEN"
'';
}
);
};
in
{
release-plz-release = runReleasePlzOnCodeberg "release" "Publish unpublished versions to crates.io and tag them with a Codeberg release";
release-plz-release-pr = runReleasePlzOnCodeberg "release-pr" "Open or update the Codeberg pull request that bumps the version and changelog";
sample-machine-vm = {
type = "app";
meta.description = "Boot a sample machine with bootvine and slow sample units in QEMU";
@@ -156,6 +185,8 @@
packages = [
pkgs.prek
pkgs.convco
pkgs.release-plz
pkgs.git-cliff
];
};
}
+36
View File
@@ -0,0 +1,36 @@
[workspace]
release_always = false
semver_check = false
git_release_type = "prod"
release_commits = "^(feat|fix|perf)[(:!]"
pr_labels = ["release"]
[[package]]
name = "bootvine"
changelog_path = "CHANGELOG.md"
git_tag_name = "v{{ version }}"
git_release_name = "v{{ version }}"
[[package]]
name = "xtask"
release = false
[changelog]
tag_pattern = "v[0-9].*"
sort_commits = "oldest"
protect_breaking_commits = true
commit_parsers = [
{ message = "^feat", group = "Added" },
{ message = "^fix", group = "Fixed" },
{ message = "^doc", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Changed" },
{ message = "^style", group = "Changed" },
{ message = "^test", group = "Testing" },
{ message = "^chore: release", skip = true },
{ message = "^chore", group = "Miscellaneous" },
{ message = "^ci", group = "CI" },
{ message = "^build", group = "Build" },
{ message = "^[Mm]erge", skip = true },
{ message = ".*", group = "Other" },
]