Skip to content

Commit

Permalink
feat(ci): add protocol bumping and crates.io workspace publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
tbraun96 committed Nov 24, 2024
1 parent 10c517b commit 6de2019
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 4 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/bump_proto_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Bump Protocol Version

on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major

permissions:
contents: write

jobs:
bump-version:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: --force cargo-make

- name: Create bump branch
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git checkout -b bump-proto-version-${{ github.run_number }}
- name: Bump version
run: |
if [ "${{ github.event.inputs.version_type }}" = "patch" ]; then
cargo make bump-proto-patch
elif [ "${{ github.event.inputs.version_type }}" = "minor" ]; then
cargo make bump-proto-minor
else
cargo make bump-proto-major
fi
- name: Run clippy
run: cargo clippy --tests

- name: Commit changes
run: |
VERSION=$(cargo pkgid --package citadel_sdk | cut -d# -f2 | cut -d: -f2)
git add .
git commit -am "upgrade: protocol version ${VERSION} release (${{ github.event.inputs.version_type }})"
- name: Push changes
run: git push origin bump-proto-version-${{ github.run_number }}

- name: Merge to main
run: |
git checkout main
git merge bump-proto-version-${{ github.run_number }}
git push origin main
- name: Delete temporary branch
run: git push origin --delete bump-proto-version-${{ github.run_number }}
38 changes: 35 additions & 3 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,46 @@ fn maybe_extract_value_for(line: &str, line_str_name: &str) -> Option<u8> {
}
'''

[tasks.bump-proto]
dependencies = ["bump-proto-inner"]
[tasks.format-proto]
command = "cargo"
args = ["fmt", "--package", "citadel_proto"]

[tasks.bump-proto-major]
env = { "BUMP_PROTO_CITADEL_MAJOR" = "true" }
run_task = [
{ name = "bump-proto-inner" },
{ name = "format-proto" }
]

[tasks.bump-proto-minor]
env = { "BUMP_PROTO_CITADEL_MINOR" = "true" }
run_task = [
{ name = "bump-proto-inner" },
{ name = "format-proto" }
]

[tasks.bump-proto-patch]
env = { "BUMP_PROTO_CITADEL_PATCH" = "true" }
run_task = [
{ name = "bump-proto-inner" },
{ name = "format-proto" }
]

[tasks.publish-install-deps]
install_crate = { crate_name = "cargo-workspaces", binary = "cargo", test_arg = ["workspaces", "--help"] }

[tasks.publish-bump-version-patch]
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
command = "cargo"
args = ["workspaces", "version", "minor"]

[tasks.publish-bump-version-minor]
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
command = "cargo"
args = ["workspaces", "version", "minor"]

[tasks.publish-bump-version-major]
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
command = "cargo"
args = ["workspaces", "version", "major"]

Expand All @@ -261,4 +284,13 @@ dependencies = ["publish-install-deps", "publish-bump-version-major"]

[tasks.check-docs]
command = "cargo"
args = ["test", "--package", "citadel_sdk", "--doc"]
args = ["test", "--package", "citadel_sdk", "--doc"]

[tasks.install-cargo-wasix]
command = "cargo"
args = ["install", "cargo-wasix"]

[tasks.wasix]
command = "cargo"
args = ["--config=Cargo.wasix.toml", "wasix", "${@}", "--profile=wasix"]
dependencies = ["install-nextest", "install-cargo-wasix"]
2 changes: 1 addition & 1 deletion citadel_proto/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use lazy_static::lazy_static;
// Note: these values can each be up to 1024 in size, but, to be safe, we fix the upper
// bound to 255 (u8::MAX) to ensure that the values fit inside the u32 bit packer
pub const MAJOR_VERSION: u8 = 0;
pub const MINOR_VERSION: u8 = 5;
pub const MINOR_VERSION: u8 = 6;
pub const PATCH_VERSION: u8 = 0;

lazy_static! {
Expand Down

0 comments on commit 6de2019

Please sign in to comment.