-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
What -- Automate release creation Automatically create a release and publish to crates.io when the version is bumped.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
|
||
pkgv=$(cargo pkgid | awk -F'[ #]' '{print "v"$2}') | ||
|
||
ghv=$(gh release list -L 1 | awk -F" " '{print $1}') | ||
|
||
# compare versions | ||
if [[ $pkgv != $ghv ]]; then | ||
echo "'$pkgv' != '$ghv' ... creating new release tag" | ||
# create new rel tag | ||
url=$(gh release create "$pkgv" --repo="$GITHUB_REPOSITORY" --title="$pkgv" --target="$GITHUB_SHA" --generate-notes) | ||
echo "new release created at: $url" | ||
echo "created=1" >> $GITHUB_OUTPUT | ||
else | ||
echo "$pkgv == $ghv ... stopping" | ||
echo "created=0" >> $GITHUB_OUTPUT | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
on: | ||
workflow_run: | ||
workflows: | ||
- 'tests' | ||
types: | ||
- 'completed' | ||
branches: | ||
- 'main' | ||
|
||
name: Create Release | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
create_release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
outputs: | ||
created: ${{ steps.create_release_step.outputs.created }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: "cargo check" | ||
run: | | ||
cargo check | ||
- name: "create release" | ||
id: create_release_step | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
bash .github/create_rel.sh | ||
crates_io_publish: | ||
name: Publish (crates.io) | ||
needs: create_release | ||
if: needs.create_release.outputs.created == 1 | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: cargo-release Cache | ||
id: cargo_release_cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cargo/bin/cargo-release | ||
key: ${{ runner.os }}-cargo-release | ||
|
||
- run: cargo install cargo-release | ||
if: steps.cargo_release_cache.outputs.cache-hit != 'true' | ||
|
||
- name: cargo login | ||
run: cargo login ${{ secrets.CRATES_IO_API_TOKEN }} | ||
|
||
- name: "cargo release publish" | ||
run: |- | ||
cargo release \ | ||
publish \ | ||
--workspace \ | ||
--all-features \ | ||
--allow-branch main \ | ||
--no-confirm \ | ||
--execute |