From a6752cefc5c5e2a980b1da787fd5235ee2f28b20 Mon Sep 17 00:00:00 2001 From: Sebastian Alfers Date: Fri, 20 Oct 2023 12:50:02 +0200 Subject: [PATCH] Publish to Cloudsmith through Github Actions (#60) * publish github actions * start publish only if necessarey * document how to tag --- .cargo/config | 2 + .../{release.yml => publish-docs.yml} | 0 .github/workflows/publish.yml | 47 +++++++++++++++++++ Cargo.toml | 6 +-- RELEASE.md | 17 +++++++ 5 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .cargo/config rename .github/workflows/{release.yml => publish-docs.yml} (100%) create mode 100644 .github/workflows/publish.yml diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..a82255b --- /dev/null +++ b/.cargo/config @@ -0,0 +1,2 @@ +[registries.lightbend-akka-rs] +index = "sparse+https://repo.akka.io/cargo/" diff --git a/.github/workflows/release.yml b/.github/workflows/publish-docs.yml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows/publish-docs.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3960c79 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,47 @@ +name: Publish + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + if: github.event.repository.fork == false + name: Publish + runs-on: ubuntu-22.04 + env: + CARGO_REGISTRIES_AKKA_RS_INDEX: https://dl.cloudsmith.io/${{ secrets.CLOUDSMITH_AKKA_RS_ENTITLEMENT_TOKEN }}/lightbend/akka-rs/cargo/index.git + CARGO_REGISTRIES_AKKA_RS_TOKEN: ${{ secrets.CLOUDSMITH_LIGHTBEND_MACHINE_API_KEY }} + + strategy: + fail-fast: false + matrix: + PACKAGE: ["akka-persistence-rs", "akka-persistence-rs-commitlog", "akka-projection-rs", "akka-projection-rs-commitlog", "akka-projection-rs-grpc", "akka-projection-rs-storage"] + + steps: + - name: Checkout + # https://github.com/actions/checkout/releases + # v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + + - name: Update Rust + run: | + rustup update + + - name: Install protoc + # https://github.com/taiki-e/install-action/releases + # v2.20.3 + uses: taiki-e/install-action@47d27149ff6b3422864ec504071d5cc7873d642e + with: + tool: protoc@${{ env.PROTOC_VERSION }} + + - name: Cache Rust + # https://github.com/Swatinem/rust-cache/releases + # v2.7.0 + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 + + - name: Publish ${{ matrix.PACKAGE }} + if: startsWith(github.event.ref, 'refs/tags/v') + run: cargo publish --registry AKKA_RS -p ${{ matrix.PACKAGE }} diff --git a/Cargo.toml b/Cargo.toml index b3113b6..7f1f19a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,9 +65,9 @@ yew = { version = "0.20" } # THE VERSIONS HERE SHOULD BE THE SAME AS PER `workspace.package.version`. -akka-persistence-rs = { path = "akka-persistence-rs", version = "0.1.0" } -akka-persistence-rs-commitlog = { path = "akka-persistence-rs-commitlog", version = "0.1.0" } -akka-projection-rs = { path = "akka-projection-rs", version = "0.1.0" } +akka-persistence-rs = { path = "akka-persistence-rs", version = "0.1.0", registry = "lightbend-akka-rs" } +akka-persistence-rs-commitlog = { path = "akka-persistence-rs-commitlog", version = "0.1.0", registry = "lightbend-akka-rs" } +akka-projection-rs = { path = "akka-projection-rs", version = "0.1.0", registry = "lightbend-akka-rs" } [profile.bench-debug] inherits = "release" diff --git a/RELEASE.md b/RELEASE.md index 1f426b1..f04f05d 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,6 +5,7 @@ Releasing 2. Change the `dependency.akka-*` versions to be the same version number as per step 1. 3. Commit the changes and tag with the version using `v` as a prefix e.g. 1.0.0 would be "v1.0.0". 4. Perform the commands below, and in the same order... +5. To publish from CI, tag the release as per step 1 and [run the job manually](https://github.com/lightbend/akka-edge-rs/actions/workflows/publish.yml). ``` cargo publish -p akka-persistence-rs @@ -13,4 +14,20 @@ cargo publish -p akka-projection-rs cargo publish -p akka-projection-rs-commitlog cargo publish -p akka-projection-rs-grpc cargo publish -p akka-projection-rs-storage +``` + +### Publish to Cloudsmith +Ensure the following env vars are available: +``` +export CARGO_REGISTRIES_AKKA_RS_INDEX=https://dl.cloudsmith.io/{entitlement-token}/lightbend/akka-rs/cargo/index.git +export CARGO_REGISTRIES_AKKA_RS_TOKEN={api-key} +``` + +Credentials bound to the `cloudsmith-machine` user should be used: +- `{entitlement-token` can be found [here](https://cloudsmith.io/~lightbend/repos/akka-rs/entitlements/) +- `{api-key}` can be found [here](https://cloudsmith.io/user/settings/api/) + +Also make sure to specify the registry `--registry` accordingly, for example: +``` +cargo publish -p akka-persistence-rs-commitlog --registry AKKA_RS ``` \ No newline at end of file