From 3c50ed562bbc3dfa8be24828d5b9fc8c9bc815c7 Mon Sep 17 00:00:00 2001 From: Hendrik Maus Date: Wed, 13 Apr 2022 07:43:11 +0200 Subject: [PATCH 1/5] ci: include crates.io publishing in the deployment workflow --- .github/workflows/cd.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9db3545e9..98446b4db 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -120,10 +120,27 @@ jobs: | awk '{print $1}' > "${file}.sha256" done - - name: Create GitHub Release + - name: Release | GitHub if: ${{ steps.release.outputs.release-detected == 'true' }} uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.release.outputs.tag-name }} name: ${{ steps.release.outputs.tag-name }} files: ${{ env.PROJ_NAME }}-*/${{ env.PROJ_NAME }}-* + + - name: Release | Crates.io + if: ${{ steps.release.outputs.release-detected == 'true' }} + working-directory: ./release-operator + env: + RUST_LOG: info + run: | + # Publish to crates.io + cargo run -- publish \ + --token ${{ secrets.CARGO_REGISTRY_TOKEN }} \ + --crate ../fj-app \ + --crate ../fj-debug \ + --crate ../fj-host \ + --crate ../fj-kernel \ + --crate ../fj-math \ + --crate ../fj-operations \ + --crate ../fj From 077c37761b7451a5e1da387bd63c383b03f9757e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 13 Apr 2022 11:21:54 +0200 Subject: [PATCH 2/5] Update list of crates to release `fj-debug` has been renamed to `fj-interop`. --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 98446b4db..7a7c78ea8 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -138,8 +138,8 @@ jobs: cargo run -- publish \ --token ${{ secrets.CARGO_REGISTRY_TOKEN }} \ --crate ../fj-app \ - --crate ../fj-debug \ --crate ../fj-host \ + --crate ../fj-interop \ --crate ../fj-kernel \ --crate ../fj-math \ --crate ../fj-operations \ From a449b1c5299809db480444ce42513d10cc94c893 Mon Sep 17 00:00:00 2001 From: Hendrik Maus Date: Wed, 13 Apr 2022 08:10:09 +0200 Subject: [PATCH 3/5] ci: determine if the current crate is ahead or behind the registry --- release-operator/src/registry.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/release-operator/src/registry.rs b/release-operator/src/registry.rs index 3f40c0f07..02b39bdda 100644 --- a/release-operator/src/registry.rs +++ b/release-operator/src/registry.rs @@ -17,9 +17,14 @@ pub struct Crate { } enum CrateState { + /// Our crate version is ahead of the registry and should be published + Ahead, + /// Our crate version is behind the registry; you'll be warned about this + Behind, + /// Our crate version matches the registry version Published, + /// We encountered an unknown state while processing the crate Unknown, - Outdated, } impl Registry { @@ -36,8 +41,8 @@ impl Registry { c.validate()?; match c.determine_state()? { - CrateState::Published => continue, - CrateState::Unknown | CrateState::Outdated => { + CrateState::Published | CrateState::Behind => continue, + CrateState::Unknown | CrateState::Ahead => { c.submit(&self.token, self.dry_run)?; } } @@ -72,7 +77,7 @@ impl Crate { .context("search crates.io for published crate version")?; log::debug!("{self} found as {version} on their side"); - version + semver::Version::from_str(&version).context("parse their version")? }; let ours = { @@ -93,7 +98,7 @@ impl Crate { .find(|p| p.name == name) .ok_or_else(|| anyhow!("could not find package"))?; - let version = package.version.to_string(); + let version = package.version.to_owned(); log::debug!("{self} found as {version} on our side"); version @@ -104,7 +109,12 @@ impl Crate { return Ok(CrateState::Published); } - Ok(CrateState::Outdated) + if ours < theirs { + log::warn!("{self} has already been published as {ours}, which is a newer version"); + return Ok(CrateState::Behind) + } + + Ok(CrateState::Ahead) } fn submit(&self, token: &SecStr, dry_run: bool) -> anyhow::Result<()> { From 48393314dd4419544301ca318bdd8d9aeb397eaa Mon Sep 17 00:00:00 2001 From: Hendrik Maus Date: Wed, 13 Apr 2022 08:13:07 +0200 Subject: [PATCH 4/5] chore: cargo fmt --- release-operator/src/registry.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release-operator/src/registry.rs b/release-operator/src/registry.rs index 02b39bdda..55049e108 100644 --- a/release-operator/src/registry.rs +++ b/release-operator/src/registry.rs @@ -77,7 +77,8 @@ impl Crate { .context("search crates.io for published crate version")?; log::debug!("{self} found as {version} on their side"); - semver::Version::from_str(&version).context("parse their version")? + semver::Version::from_str(&version) + .context("parse their version")? }; let ours = { @@ -111,7 +112,7 @@ impl Crate { if ours < theirs { log::warn!("{self} has already been published as {ours}, which is a newer version"); - return Ok(CrateState::Behind) + return Ok(CrateState::Behind); } Ok(CrateState::Ahead) From f0f2d7029267c80d4cc09ca040b004f81f38f378 Mon Sep 17 00:00:00 2001 From: Hendrik Maus Date: Wed, 13 Apr 2022 09:31:09 +0200 Subject: [PATCH 5/5] chore: bump version --- release-operator/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-operator/Cargo.toml b/release-operator/Cargo.toml index 0ab46b865..b142974c7 100644 --- a/release-operator/Cargo.toml +++ b/release-operator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "release-operator" -version = "0.2.0" +version = "0.3.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html