Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify common rust version correctly #134

Merged
merged 5 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 20 additions & 67 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Rust

permissions:
pull-requests: write
contents: write

on:
push:
branches: [ master ]
Expand Down Expand Up @@ -46,71 +50,20 @@ jobs:
- name: Run cargo fmt
run: cargo fmt --check

publish:
runs-on: ubuntu-20.04
needs: [tests, clippy, cargo-fmt]
if: github.ref == 'refs/heads/master'

release-plz:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- 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 --force '*' \
--skip-published --no-git-commit --allow-dirty \
--tag-existing --tag-prefix 'v' \
--tag-msg 'crates.io snapshot' --tag-msg $'%{\n - %n: 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.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: |
${{ steps.extract-release-notes.outputs.release_notes }}

#### Crate Links

${{ steps.tag-and-publish.outputs.git_tag_message }}
- 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/release-plz-action@v0.5
env:
# https://marcoieni.github.io/release-plz/github-action.html#triggering-further-workflow-runs
GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ members = [
"benchmarks",
]

[workspace.metadata.workspaces]
[workspace.package]
# shared version of all public crates in the workspace
version = "0.10.3"
exclude = [ "fuzz/*", "benchmarks" ]
2 changes: 1 addition & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "benchmarks"
version = "0.0.0"
version.workspace = true
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion borsh-derive-internal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-derive-internal"
version = "0.0.0"
version.workspace = true
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion borsh-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-derive"
version = "0.0.0"
version.workspace = true
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion borsh-schema-derive-internal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-schema-derive-internal"
version = "0.0.0"
version.workspace = true
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion borsh/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh"
version = "0.0.0"
version.workspace = true
authors = ["Near Inc <hello@near.org>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz-run/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-fuzz"
version = "0.0.0"
version.workspace = true
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"
publish = false
Expand Down
16 changes: 16 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[workspace]
# Use `borsh` crate CHANGELOG as top-level one
changelog_update = false

[[package]]
name = "borsh"
changelog_update = true
changelog_path = "./CHANGELOG.md"

[[package]]
name = "fuzz-run"
publish = false

[[package]]
name = "benchmark"
publish = false