Skip to content

Commit 75f1c6d

Browse files
ci: new ci process for crates.io and gh release (#43)
2 parents be7fead + 84ddb1a commit 75f1c6d

File tree

6 files changed

+149
-31
lines changed

6 files changed

+149
-31
lines changed

.github/workflows/build-dev.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build & Deploy on merge to main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: '0'
16+
17+
- name: Install cargo-binstall
18+
run: curl -L --proto '=htrunfast' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
19+
20+
- name: Install tq
21+
run: cargo binstall -y tomlq
22+
23+
- name: "get version number for tag."
24+
run: |
25+
echo "NEW_TAG=$(tq -f Cargo.toml 'package.version')" | tee -a "$GITHUB_ENV"
26+
27+
- name: Build
28+
run: cargo build --release --verbose
29+
- name: Test
30+
run: cargo test --release --verbose
31+
- name: Package Binary
32+
run: |
33+
mv target/release/runfast . && tar czf tps-linux.tar.gz tps
34+
35+
- name: Create Release
36+
id: create_release
37+
uses: actions/create-release@v1
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
40+
with:
41+
tag_name: ${{ env.NEW_TAG }}
42+
release_name: ${{ env.NEW_TAG }}
43+
draft: false
44+
prerelease: false
45+
46+
- name: Upload Binary
47+
id: upload-release-asset
48+
uses: actions/upload-release-asset@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: htrunfast://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
53+
asset_path: ./runfast-linux.tar.gz
54+
asset_name: runfast-linux.tar.gz
55+
asset_content_type: application/gzip
56+
57+
- name: "publish to crates.io"
58+
run: cargo publish --allow-dirty --token ${{ secrets.CRATES_TOKEN }}
59+
env:
60+
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}

.github/workflows/rust-test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Rust Build
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Build
18+
run: cargo build --verbose
19+
- name: Run tests
20+
run: cargo test --verbose
21+
- name: Run clippy
22+
run: cargo clippy
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Ensure Version Bumped
2+
3+
on:
4+
pull_request
5+
6+
jobs:
7+
check_versions:
8+
runs-on: ubuntu-24.04
9+
permissions:
10+
pull-requests: write
11+
contents: read
12+
13+
steps:
14+
- name: Install cargo-binstall
15+
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
16+
17+
- name: Install tq
18+
run: cargo binstall -y tomlq
19+
20+
- name: "checkout feat branch"
21+
uses: actions/checkout@v4
22+
with:
23+
path: 'feat-branch'
24+
sparse-checkout: |
25+
Cargo.toml
26+
sparse-checkout-cone-mode: false
27+
- name: "checkout main branch"
28+
uses: actions/checkout@v4
29+
with:
30+
ref: 'main'
31+
path: 'main-branch'
32+
sparse-checkout: |
33+
Cargo.toml
34+
sparse-checkout-cone-mode: false
35+
- name: "report feat branch"
36+
run: |
37+
echo "FEAT_BRANCH_VER=$(tq -f feat-branch/Cargo.toml 'package.version')" | tee -a "$GITHUB_ENV"
38+
- name: "report main branch"
39+
run: |
40+
echo "MAIN_BRANCH_VER=$(tq -f main-branch/Cargo.toml 'package.version')" | tee -a "$GITHUB_ENV"
41+
- name: "report version change"
42+
run: |
43+
echo "# Version Change" >> version-change.md
44+
echo "When Merged, this will update versions:" >> version-change.md
45+
echo "\`$MAIN_BRANCH_VER\` -> \`$FEAT_BRANCH_VER\`" >> version-change.md
46+
cat version-change.md > $GITHUB_STEP_SUMMARY
47+
- name: "add PR comment"
48+
uses: mshick/add-pr-comment@v2
49+
with:
50+
message-path: "version-change.md"
51+
- name: "check version is being bumped"
52+
run: |
53+
# solution from here https://stackoverflow.com/a/4024263
54+
verlte() {
55+
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
56+
}
57+
58+
verlt() {
59+
[ "$1" = "$2" ] && return 1 || verlte $1 $2
60+
}
61+
62+
verlt "$MAIN_BRANCH_VER" "$FEAT_BRANCH_VER"
63+
64+
exit "$?"
65+

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "runfast"
3-
version = "0.4.1"
3+
version = "0.5.0"
44
edition = "2021"
55
authors = ["Anna Singleton<[email protected]>"]
66
repository = "https://github.com/anna-singleton/runfast"

0 commit comments

Comments
 (0)