Skip to content

Commit 49be8ad

Browse files
committed
crates.io workflow
1 parent 0033c1b commit 49be8ad

File tree

2 files changed

+144
-1
lines changed

2 files changed

+144
-1
lines changed

.github/workflows/release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Triggers on version tags like v0.1.0, v1.0.0
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
# Run tests before releasing
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
22+
- name: Run tests
23+
run: cargo test --lib
24+
25+
- name: Check formatting
26+
run: cargo fmt --all -- --check
27+
28+
- name: Clippy
29+
run: cargo clippy --all-targets --all-features -- -D warnings
30+
31+
# Publish to crates.io
32+
publish:
33+
name: Publish to crates.io
34+
runs-on: ubuntu-latest
35+
needs: test
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Setup Rust
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Publish to crates.io
43+
env:
44+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
45+
run: cargo publish
46+
47+
# Create GitHub Release with binaries
48+
release:
49+
name: Build Release Binaries
50+
runs-on: ${{ matrix.os }}
51+
needs: test
52+
strategy:
53+
matrix:
54+
include:
55+
- os: ubuntu-latest
56+
target: x86_64-unknown-linux-gnu
57+
artifact: cargo-jam-linux-x86_64
58+
- os: macos-latest
59+
target: x86_64-apple-darwin
60+
artifact: cargo-jam-macos-x86_64
61+
- os: macos-latest
62+
target: aarch64-apple-darwin
63+
artifact: cargo-jam-macos-aarch64
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Setup Rust
69+
uses: dtolnay/rust-toolchain@stable
70+
with:
71+
targets: ${{ matrix.target }}
72+
73+
- name: Build release binary
74+
run: cargo build --release --target ${{ matrix.target }}
75+
76+
- name: Package binary (Unix)
77+
run: |
78+
cd target/${{ matrix.target }}/release
79+
tar -czvf ../../../${{ matrix.artifact }}.tar.gz cargo-jam
80+
cd ../../..
81+
82+
- name: Upload artifact
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: ${{ matrix.artifact }}
86+
path: ${{ matrix.artifact }}.tar.gz
87+
88+
# Create GitHub Release
89+
github-release:
90+
name: Create GitHub Release
91+
runs-on: ubuntu-latest
92+
needs: [release, publish]
93+
permissions:
94+
contents: write
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- name: Download all artifacts
99+
uses: actions/download-artifact@v4
100+
with:
101+
path: artifacts
102+
103+
- name: Create Release
104+
uses: softprops/action-gh-release@v1
105+
with:
106+
files: artifacts/**/*.tar.gz
107+
generate_release_notes: true
108+
draft: false
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ cargo, make me a JAM service
66

77
A Rust cargo subcommand for generating and building JAM (Join-Accumulate Machine) services for Polkadot. Follows the [cargo-generate](https://github.com/cargo-generate/cargo-generate) project architecture while providing JAM-specific tooling.
88

9+
## Demo
10+
11+
12+
913
## Installation
1014

1115
### Install From crates.io
@@ -453,7 +457,36 @@ The testnet tests will:
453457
2. Build it to a `.jam` blob
454458
3. Deploy it to the running testnet using `cargo jam deploy`
455459

456-
## Publishing to crates.io
460+
## Publishing & Releases
461+
462+
### Automated Releases (Recommended)
463+
464+
This repo has CI/CD that automatically publishes to crates.io when you create a version tag:
465+
466+
**One-time setup:**
467+
1. Get your crates.io API token from https://crates.io/settings/tokens
468+
2. Add it as a GitHub secret: Settings → Secrets → Actions → New secret
469+
- Name: `CARGO_REGISTRY_TOKEN`
470+
- Value: your token
471+
472+
**To release a new version:**
473+
```bash
474+
# Update version in Cargo.toml
475+
# Commit changes
476+
git add . && git commit -m "Release v0.1.0"
477+
478+
# Create and push a version tag
479+
git tag v0.1.0
480+
git push origin main --tags
481+
```
482+
483+
This triggers the release workflow which:
484+
1. Runs all tests and lints
485+
2. Publishes to crates.io
486+
3. Builds binaries for Linux and macOS
487+
4. Creates a GitHub Release with downloadable binaries
488+
489+
### Manual Publishing
457490

458491
```bash
459492
# Login to crates.io

0 commit comments

Comments
 (0)