Skip to content

Commit 3b4afcb

Browse files
committed
Wire crates.io composite action in release.yml
1 parent cb64688 commit 3b4afcb

File tree

1 file changed

+26
-49
lines changed

1 file changed

+26
-49
lines changed

.github/workflows/release.yml

Lines changed: 26 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -59,55 +59,6 @@ jobs:
5959
file: ${{ env.DOCKER_FILE }}
6060
push: true
6161
tags: ${{ steps.meta.outputs.tags }}
62-
63-
check-deploy-crates-io:
64-
runs-on: ubuntu-22.04
65-
outputs:
66-
should-deploy: ${{ steps.check_version.outputs.should_deploy }}
67-
steps:
68-
- name: Checkout sources
69-
uses: actions/checkout@v3
70-
71-
- name: Check crate latest version
72-
id: check_version
73-
run: |
74-
LATEST_REMOTE_VERSION=$(wget -q -O - https://crates.io/api/v1/crates/mithril-stm | jq -r '.crate.newest_version')
75-
LOCAL_VERSION=$(cargo metadata --quiet --no-deps | jq -r '.packages[] | select(.name=="mithril-stm") | .version')
76-
echo "Latest crate.io version: $LATEST_REMOTE_VERSION"
77-
echo "Local version: $LOCAL_VERSION"
78-
79-
if [ "$LOCAL_VERSION" != "$LATEST_REMOTE_VERSION" ]; then
80-
echo "Local version is newer than remote version: we will publish to crates.io"
81-
echo "should_deploy=true" >> $GITHUB_OUTPUT
82-
else
83-
echo "Local version and remote version are the same: no need to publish to crates.io"
84-
echo "should_deploy=false" >> $GITHUB_OUTPUT
85-
fi
86-
87-
deploy-crates-io:
88-
runs-on: ubuntu-22.04
89-
needs: check-deploy-crates-io
90-
if: needs.check-deploy-crates-io.outputs.should-deploy == 'true'
91-
steps:
92-
- name: Checkout sources
93-
uses: actions/checkout@v3
94-
95-
- name: Install stable toolchain
96-
uses: dtolnay/rust-toolchain@master
97-
with:
98-
toolchain: stable
99-
100-
- name: Cargo publish dry run
101-
shell: bash
102-
run: cargo publish -p mithril-stm --dry-run
103-
104-
- name: Cargo package list
105-
shell: bash
106-
run: cargo package -p mithril-stm --list
107-
108-
- name: Cargo publish
109-
shell: bash
110-
run: cargo publish -p mithril-stm --token ${{ secrets.CRATES_IO_API_TOKEN }}
11162

11263
deploy-release:
11364
strategy:
@@ -208,3 +159,29 @@ jobs:
208159
loki_ingest_host: ${{ vars.LOKI_INGEST_HOST }}
209160
loki_ingest_username: ${{ secrets.LOKI_INGEST_USERNAME }}
210161
loki_ingest_password: ${{ secrets.LOKI_INGEST_PASSWORD }}
162+
163+
publish-crate:
164+
strategy:
165+
fail-fast: false
166+
matrix:
167+
package: [ mithril-stm ]
168+
include:
169+
- package: mithril-stm
170+
api_token_secret_name: CRATES_IO_API_TOKEN
171+
172+
runs-on: ubuntu-22.04
173+
steps:
174+
- name: Checkout sources
175+
uses: actions/checkout@v3
176+
177+
- name: Install stable toolchain
178+
uses: dtolnay/rust-toolchain@master
179+
with:
180+
toolchain: stable
181+
182+
- name: Publish package to crates.io
183+
uses: ./.github/workflows/actions/publish-crate-package
184+
with:
185+
dry_run: "false"
186+
package: ${{ matrix.package }}
187+
api_token: ${{ secrets[matrix.api_token_secret_name] }}

0 commit comments

Comments
 (0)