-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(repo): Adjust publish crates to run with workflow dispatch
- Loading branch information
1 parent
825fd5a
commit 0818406
Showing
2 changed files
with
43 additions
and
8 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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
name: Publish on Crates.io | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version to release" | ||
required: true | ||
type: string | ||
|
||
env: | ||
CI: true | ||
RUST_VERSION: 1.81.0 | ||
RUST_NIGHTLY_VERSION: nightly-2024-11-06 | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
|
@@ -22,14 +26,47 @@ jobs: | |
name: Publish on Crates.io | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check Cargo.toml version | ||
id: check-version | ||
run: | | ||
CURRENT_VERSION=$(grep -m1 '^version =' Cargo.toml | cut -d '"' -f2) | ||
if [ "$CURRENT_VERSION" == "${{ inputs.version }}" ]; then | ||
echo "skip_steps=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "skip_steps=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Configure Git | ||
if: ${{ inputs.version != '' && steps.check-version.outputs.skip_steps == 'false' }} | ||
run: | | ||
git config --global user.name GitHub Actions | ||
git config user.email [email protected] | ||
- name: Install Rust | ||
uses: ./.github/actions/setup-rust | ||
with: | ||
toolchain: ${{ env.RUST_VERSION }} | ||
cache: false | ||
toolchain: ${{ env.RUST_NIGHTLY_VERSION }} | ||
target: x86_64-unknown-linux-gnu,wasm32-unknown-unknown | ||
|
||
- name: Setup Node && PNPM | ||
if: ${{ inputs.version != '' && steps.check-version.outputs.skip_steps == 'false' }} | ||
uses: ./.github/actions/setup-node | ||
|
||
- name: Bump Version | ||
if: ${{ inputs.version != '' && steps.check-version.outputs.skip_steps == 'false' }} | ||
run: | | ||
make bump-version VERSION=${{ inputs.version }} | ||
git add . | ||
git commit -m "Bump version to v${{ inputs.version }}" | ||
git push | ||
- name: Publish Crate | ||
uses: katyo/publish-crates@v2 | ||
id: publish-crates | ||
|
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