Skip to content

Commit 66d583b

Browse files
committed
Add crate publication to crates.io
1 parent 9ad265b commit 66d583b

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,63 @@ jobs:
6060
push: true
6161
tags: ${{ steps.meta.outputs.tags }}
6262

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: actions-rs/toolchain@v1
97+
with:
98+
profile: minimal
99+
toolchain: stable
100+
101+
- name: Cargo publish dry run
102+
uses: actions-rs/cargo@v1
103+
with:
104+
command: publish
105+
args: -p mithril-stm --dry-run
106+
107+
- name: Cargo package list
108+
uses: actions-rs/cargo@v1
109+
with:
110+
command: package
111+
args: -p mithril-stm --list
112+
113+
# We use the '--dry-run' arg until we have a valid CRATES_IO_API_TOKEN to avoid the workflow to crash
114+
- name: Cargo publish
115+
uses: actions-rs/cargo@v1
116+
with:
117+
command: publish
118+
args: -p mithril-stm --token ${{ secrets.CRATES_IO_API_TOKEN }} --dry-run
119+
63120
deploy-release:
64121
strategy:
65122
fail-fast: false

mithril-stm/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ license = { workspace = true }
99
repository = { workspace = true }
1010
description = "A Rust implementation of Mithril Stake-based Threshold Multisignatures (STMs)."
1111
categories = ["cryptography"]
12+
include = [
13+
"**/*.rs",
14+
"Cargo.toml",
15+
"README.md",
16+
".gitignore",
17+
]
1218

1319
[lib]
1420
crate-type = ["lib", "cdylib", "staticlib"]

0 commit comments

Comments
 (0)