feat(release): add semantic-release auto versioning
- Add .releaserc.json: conventional commits -> semantic version bump (major/minor/patch), updates Cargo.toml + Cargo.lock version, writes CHANGELOG.md, commits as 'chore(release): X.Y.Z [skip ci]' - Add release.yml: runs semantic-release on main push, then triggers publish.yml via workflow_dispatch with the new tag - Update publish.yml: add workflow_dispatch input (tag) so release workflow can trigger publish directly (GITHUB_TOKEN tag pushes do not trigger 'on: push: tags'); still supports manual tag pushes
This commit is contained in:
@@ -3,6 +3,15 @@ name: Publish to crates.io
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: ["v*.*.*"]
|
tags: ["v*.*.*"]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: "Git tag to publish (e.g. v0.2.0). Defaults to latest tag."
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
@@ -10,7 +19,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.tag || github.event.ref || github.ref }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
- name: Publish mytheclipse
|
- name: Publish mytheclipse
|
||||||
run: cargo publish --allow-dirty --no-verify
|
run: cargo publish --allow-dirty --no-verify
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Semantic Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Rust toolchain
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "lts/*"
|
||||||
|
|
||||||
|
- name: Install semantic-release
|
||||||
|
run: |
|
||||||
|
npm install -D \
|
||||||
|
semantic-release \
|
||||||
|
@semantic-release/exec \
|
||||||
|
@semantic-release/git \
|
||||||
|
@semantic-release/changelog \
|
||||||
|
@semantic-release/github
|
||||||
|
|
||||||
|
- name: Run semantic-release
|
||||||
|
id: semantic-release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: npx semantic-release
|
||||||
|
|
||||||
|
- name: Trigger crate publish
|
||||||
|
if: ${{ steps.semantic-release.outputs.new_release_published == 'true' }}
|
||||||
|
env:
|
||||||
|
RELEASE_VERSION: ${{ steps.semantic-release.outputs.next_release_version }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
TAG="v${RELEASE_VERSION}"
|
||||||
|
echo "Tagging and dispatching publish for $TAG"
|
||||||
|
gh workflow run publish.yml --ref main -f tag="$TAG"
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"branches": ["main"],
|
||||||
|
"plugins": [
|
||||||
|
"@semantic-release/commit-analyzer",
|
||||||
|
"@semantic-release/release-notes-generator",
|
||||||
|
"@semantic-release/changelog",
|
||||||
|
["@semantic-release/exec", {
|
||||||
|
"prepareCmd": "sed -i 's/^version = \\\"[^\\\"]*\\\"/version = \\\"${nextRelease.version}\\\"/' Cargo.toml && cargo check --locked"
|
||||||
|
}],
|
||||||
|
["@semantic-release/git", {
|
||||||
|
"assets": ["Cargo.toml", "Cargo.lock", "CHANGELOG.md"],
|
||||||
|
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
||||||
|
}],
|
||||||
|
["@semantic-release/github", {
|
||||||
|
"assets": []
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user