From 706c397312fdcfa9eb0ab49832469b12c6e7de5e Mon Sep 17 00:00:00 2001 From: sebastian-alfers Date: Thu, 19 Oct 2023 17:18:40 +0200 Subject: [PATCH 1/5] publish github actions --- .cargo/config | 2 ++ .github/workflows/publish.yml | 46 +++++++++++++++++++++++++++++++++++ Cargo.toml | 6 ++--- RELEASE.md | 16 ++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .cargo/config 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/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2c660c5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,46 @@ +name: Publish + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + 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: # align with publish-test-reports.yml + SCALA_VERSION: [2.13, 3.3] + 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 }} + 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..96a0905 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -13,4 +13,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 From 1d5cf86663e85e48fd7cc8f402ee7d771a0799fa Mon Sep 17 00:00:00 2001 From: sebastian-alfers Date: Thu, 19 Oct 2023 17:32:03 +0200 Subject: [PATCH 2/5] start publish only if necessarey --- .github/workflows/{release.yml => publish-docs.yml} | 0 .github/workflows/publish.yml | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename .github/workflows/{release.yml => publish-docs.yml} (100%) 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 index 2c660c5..d3be0fe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,6 +8,8 @@ permissions: jobs: publish: + if: github.event.repository.fork == false + if: startsWith(github.event.ref, 'refs/tags/v') name: Publish runs-on: ubuntu-22.04 env: @@ -16,8 +18,7 @@ jobs: strategy: fail-fast: false - matrix: # align with publish-test-reports.yml - SCALA_VERSION: [2.13, 3.3] + 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: From 08327d225de23873203b5a27e09107602d6f3f47 Mon Sep 17 00:00:00 2001 From: sebastian-alfers Date: Thu, 19 Oct 2023 17:46:00 +0200 Subject: [PATCH 3/5] move tag check --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d3be0fe..06f2187 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,7 +9,6 @@ permissions: jobs: publish: if: github.event.repository.fork == false - if: startsWith(github.event.ref, 'refs/tags/v') name: Publish runs-on: ubuntu-22.04 env: @@ -23,6 +22,7 @@ jobs: steps: - name: Checkout + if: startsWith(github.event.ref, 'refs/tags/v') # https://github.com/actions/checkout/releases # v4.1.0 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 From 88da56d1b3fce8aa890c649e6f302135272157ab Mon Sep 17 00:00:00 2001 From: sebastian-alfers Date: Fri, 20 Oct 2023 11:01:35 +0200 Subject: [PATCH 4/5] move tag condition to actual publish step --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 06f2187..3960c79 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,6 @@ jobs: steps: - name: Checkout - if: startsWith(github.event.ref, 'refs/tags/v') # https://github.com/actions/checkout/releases # v4.1.0 uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 @@ -44,4 +43,5 @@ jobs: 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 }} From 43b77c7de8f702abfc1d793720884c8810527090 Mon Sep 17 00:00:00 2001 From: sebastian-alfers Date: Fri, 20 Oct 2023 11:06:45 +0200 Subject: [PATCH 5/5] document how to tag --- RELEASE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE.md b/RELEASE.md index 96a0905..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