Skip to content

Commit

Permalink
chore: update workflow for release
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Nov 28, 2024
1 parent b47eb48 commit bfc4d0f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,26 @@ jobs:
- name: Cargo Clippy
run: cargo +nightly clippy --all-features --workspace -- -D warnings
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
packages: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Release Plz
uses: MarcoIeni/[email protected]
with:
command: release
release-pr:
needs:
- build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
name: Release
name: Release PR
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -67,3 +83,5 @@ jobs:
uses: actions/checkout@v4
- name: Release Plz
uses: MarcoIeni/[email protected]
with:
command: release-pr
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[workspace]
edition = "2021"
resolver = "2"
members = ["crates/*"]
22 changes: 13 additions & 9 deletions crates/gh-workflow/tests/ci.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use ctx::Context;
use gh_workflow::*;
use release_plz::Release;
use release_plz::{Command, Release};
use toolchain::Toolchain;

#[test]
Expand Down Expand Up @@ -51,12 +50,16 @@ fn generate() {
.contents(Level::Write);

let release = Job::new("Release")
.cond(
Context::github()
.event_name()
.eq("push".into())
.and(Context::github().ref_().eq("refs/heads/main".into())),
)
.add_env(Env::github())
.add_env(Env::new(
"CARGO_REGISTRY_TOKEN",
"${{ secrets.CARGO_REGISTRY_TOKEN }}",
))
.permissions(permissions.clone())
.add_step(Step::checkout())
.add_step(Release::default().command(Command::Release));

let release_pr = Job::new("Release PR")
.add_needs(build.clone())
.add_env(Env::github())
.add_env(Env::new(
Expand All @@ -65,13 +68,14 @@ fn generate() {
))
.permissions(permissions)
.add_step(Step::checkout())
.add_step(Release::default());
.add_step(Release::default().command(Command::ReleasePR));

Workflow::new("CI")
.add_env(flags)
.on(event)
.add_job("build", build)
.add_job("release", release)
.add_job("release-pr", release_pr)
.generate()
.unwrap();
}

0 comments on commit bfc4d0f

Please sign in to comment.