-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
56 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,7 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
# Check for updates every Monday | ||
schedule: | ||
interval: "weekly" |
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 |
---|---|---|
@@ -1,67 +1,72 @@ | ||
name: Release | ||
# Name of the workflow: you can change it. | ||
name: Release-plz | ||
|
||
permissions: | ||
# Used to create and update pull requests. | ||
pull-requests: write | ||
# Used to push to branches, push tags, and create releases. | ||
contents: write | ||
|
||
# The action runs on every push to the main branch. | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_type: | ||
description: 'Release type' | ||
required: true | ||
default: 'minor' | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
crate: | ||
description: 'Crate to release' | ||
required: true | ||
default: 'function-timer-macro' | ||
type: choice | ||
options: | ||
- function-timer-macro | ||
- function-timer | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
release: | ||
# Create a PR with the new versions and changelog, preparing the next release. | ||
# If you want release-plz to only release your packages | ||
# and you want to update `Cargo.toml` versions and changelogs by yourself, | ||
# remove this job. | ||
release-plz-pr: | ||
if: ${{ github.event_name == 'workflow_dispatch' }} | ||
name: Release-plz PR | ||
runs-on: ubuntu-latest | ||
# The concurrency block is explained below (after the code block). | ||
concurrency: | ||
group: release-plz-${{ github.ref }} | ||
cancel-in-progress: false | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run tests | ||
run: cargo test --workspace | ||
- uses: taiki-e/install-action@cargo-hack | ||
- name: Test features | ||
run: cargo hack check --workspace --each-feature --clean-per-run --no-dev-deps | ||
- name: Echo | ||
run: echo ${{ github.event.inputs.release_type }} | ||
- name: Install | ||
run: cargo install cargo-edit | ||
- name: Bump new version | ||
run: | | ||
cargo set-version -p ${{ github.event.inputs.crate }} --bump ${{ github.event.inputs.release_type }} | ||
export VERSION=`cargo tree -p ${{ github.event.inputs.crate }} --depth 0 | grep ${{ github.event.inputs.crate }} | awk '{print $2}'` | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
if [[ ${{ github.event.inputs.release_type }} != "patch" ]] && [[ ${{ github.event.inputs.crate }} == "function-timer-macro" ]]; then | ||
cargo set-version -p function-timer --bump ${{ github.event.inputs.release_type }} | ||
fi | ||
- name: Commit new version | ||
run: | | ||
git config user.name "$env.GITHUB_ACTOR" | ||
git config user.email "[email protected]" | ||
git add . | ||
git commit -m "Prepare ${{ github.event.inputs.crate }}-${{ env.VERSION }}" | ||
git push | ||
- uses: rickstaa/action-create-tag@v1 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
# `fetch-depth: 0` is needed to clone all the git history, which is necessary to | ||
# determine the next version and build the changelog. | ||
# Note that it's not needed in the `release-plz-release` job. | ||
fetch-depth: 0 | ||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Run release-plz | ||
uses: MarcoIeni/[email protected] | ||
with: | ||
tag: ${{ github.event.inputs.crate }}-${{ env.VERSION }} | ||
- name: Publish | ||
shell: bash | ||
# Run `release-plz release-pr` command. | ||
command: release-pr | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# In `release-plz-pr` this is only required if you are using a private registry. | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
run: | | ||
cargo publish -p ${{ github.event.inputs.crate }} | ||
if [[ ${{ github.event.inputs.release_type }} != "patch" ]] && [[ ${{ github.event.inputs.crate }} == "function-timer-macro" ]]; then | ||
cargo publish -p function-timer | ||
fi | ||
- name: Check | ||
run: cat Cargo.toml | ||
|
||
# Release unpublished packages. | ||
# If you want release-plz to only update your packages, | ||
# and you want to handle `cargo publish` and git tag push by yourself, | ||
# remove this job. | ||
release-plz-release: | ||
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release-plz-') }} | ||
name: Release-plz release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
# Use your favorite way to install the Rust toolchain. | ||
# The action I'm using here is a popular choice. | ||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Run release-plz | ||
uses: MarcoIeni/[email protected] | ||
with: | ||
# Run `release-plz release` command. | ||
command: release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |