Skip to content

Commit 118a345

Browse files
Merge pull request apache#238 from maxcountryman/feature/gh-action-releases
automate crate publishing
2 parents f500a42 + 9351efb commit 118a345

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.github/workflows/rust.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,16 @@ jobs:
6363
uses: coverallsapp/github-action@master
6464
with:
6565
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
67+
publish-crate:
68+
if: startsWith(github.ref, 'refs/tags/')
69+
runs-on: ubuntu-latest
70+
needs: [test]
71+
steps:
72+
- name: Set up Rust
73+
uses: hecrj/setup-rust-action@v1
74+
- uses: actions/checkout@v2
75+
- name: Publish
76+
shell: bash
77+
run: |
78+
cargo publish --token ${{ secrets.CRATES_TOKEN }}

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ serde_json = { version = "1.0", optional = true }
3434
[dev-dependencies]
3535
simple_logger = "1.6"
3636
matches = "0.1"
37+
38+
[package.metadata.release]
39+
disable-publish = true

docs/releasing.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Releasing
2+
3+
Releasing, i.e. crate publishing, has been automated via GitHub Actions.
4+
5+
We use the [`cargo release`](https://github.com/sunng87/cargo-release)
6+
subcommand to ensure correct versioning. Install via:
7+
8+
```
9+
$ cargo install cargo-release
10+
```
11+
12+
**Before releasing** ensure `CHANGELOG.md` is updated appropriately.
13+
14+
## Process
15+
16+
Using `cargo-release` we can author a new minor release like so:
17+
18+
```
19+
$ cargo release minor --skip-publish
20+
```
21+
22+
**Ensure publishing is skipped** since pushing the resulting tag upstream will
23+
handle crate publishing automatically.
24+
25+
This will create a new tag, `0.6.0` with the message,
26+
`(cargo-release) sqlparser version 0.6.0`.
27+
28+
Once the tag is created, pushing the tag upstream will trigger a publishing
29+
process to crates.io. Now to push our example tag:
30+
31+
```
32+
git push origin 0.6.0
33+
```
34+
35+
(Note that this process is fully automated; credentials
36+
for authoring in this way are securely stored in the repo secrets as
37+
`CRATE_TOKEN`.)

0 commit comments

Comments
 (0)