Skip to content

Commit 3847e50

Browse files
authored
Merge pull request #194 from plebhash/2026-01-20-publish-apps
automate publishing `sv2-apps` crates to `crates.io`
2 parents c5d41af + ec9df89 commit 3847e50

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow is used to publish sv2-apps crates to crates.io
2+
# the workflow tries to publish all the sv2-apps crates by running scripts/release-apps.sh
3+
# in case the `cargo publish` command fails, the script returns 1 and the entire workflow fails
4+
# the only exception is when the `cargo publish` command fails because the crate has already
5+
# been published, in which case the workflow continues
6+
7+
name: Release Apps
8+
9+
on:
10+
# Manually run by going to "Actions/Release" in Github and running the workflow
11+
workflow_dispatch:
12+
# every time a new release tag is created
13+
push:
14+
tags:
15+
- "v*.*.*"
16+
17+
jobs:
18+
release-apps:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- uses: actions/checkout@v4
25+
26+
- name: Install Rust (1.85)
27+
uses: dtolnay/rust-toolchain@1.85
28+
29+
- name: Login
30+
run: cargo login ${{ secrets.CRATES_IO_DEPLOY_KEY }}
31+
32+
- name: Publish stratum-apps crate
33+
run: ./scripts/release-apps.sh stratum-apps
34+
35+
- name: Publish bitcoin-core-sv2 crate
36+
run: ./scripts/release-apps.sh bitcoin-core-sv2
37+
38+
- name: Publish jd-client-sv2 crate
39+
run: ./scripts/release-apps.sh miner-apps/jd-client
40+
41+
- name: Publish translator-sv2 crate
42+
run: ./scripts/release-apps.sh miner-apps/translator
43+
44+
- name: Publish pool-sv2 crate
45+
run: ./scripts/release-apps.sh pool-apps/pool
46+
47+
# todo: uncomment after https://github.com/stratum-mining/sv2-apps/issues/24
48+
# - name: Publish jd-server crate
49+
# run: ./scripts/release-apps.sh jd-server
50+
51+
- name: Publish integration-tests-sv2 crate
52+
run: ./scripts/release-apps.sh integration-tests
53+
54+

scripts/release-apps.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
# USAGE:
4+
# ./scripts/release-apps.sh
5+
6+
# the script returns 0 on success of cargo publish, and 1 on failure
7+
# the only exception is when cargo publish fails because the crate is already published
8+
# in that case, the script also returns 0
9+
10+
CRATE_DIR="$1"
11+
12+
echo "Publishing crate in directory: $CRATE_DIR"
13+
14+
cd "$CRATE_DIR"
15+
16+
CARGO_COMMAND="cargo publish"
17+
18+
OUTPUT="$($CARGO_COMMAND 2>&1)"
19+
EXIT_CODE=$?
20+
echo "Ran cargo command, exit code was $EXIT_CODE"
21+
22+
if [ "$EXIT_CODE" -eq 0 ] ; then
23+
echo "Publish command succeeded: $CRATE_DIR"
24+
exit 0
25+
fi
26+
27+
# If cargo failed, check whether it was 'already uploaded'
28+
if echo "$OUTPUT" | grep -q "already uploaded"; then
29+
echo "Crate is already published: $CRATE_DIR"
30+
exit 0
31+
fi
32+
33+
echo "Publish command failed for $CRATE_DIR"
34+
echo "$OUTPUT"
35+
exit 1

0 commit comments

Comments
 (0)