Skip to content

Commit

Permalink
Merge pull request #1 from SpiralOutDotEu/semver
Browse files Browse the repository at this point in the history
feat(ci): ✨ Add semantic-release automation for versioning
  • Loading branch information
SpiralOutDotEu authored Oct 28, 2023
2 parents af22afa + 30fb154 commit bce9e5a
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build
run: cargo build --release

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14

- name: Install dependencies
run: |
npm install
- name: Semantic Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"conventionalCommits.scopes": [
"ci"
]
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "zk_whitelist_ci",
"version": "0.0.0-development",
"devDependencies": {
"semantic-release": "^19.0.0"
}
}

20 changes: 20 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
branches: ["main"],
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md",
}],
["@semantic-release/github", {
"assets": "target/release/zk_whitelist"
}],
["@semantic-release/exec", {
"prepareCmd": "./update_version.sh ${nextRelease.version}"
}],
["@semantic-release/git", {
"assets": ["CHANGELOG.md", "Cargo.toml"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
]
}
13 changes: 13 additions & 0 deletions update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Usage: ./update_version.sh <new-version>
# Example: ./update_version.sh 0.2.0

NEW_VERSION=$1
CARGO_TOML="Cargo.toml"

# Update the version in Cargo.toml
sed -i.bak -e "s/^version = .*/version = \"$NEW_VERSION\"/" $CARGO_TOML

# Remove the backup file created by sed
rm $CARGO_TOML.bak

0 comments on commit bce9e5a

Please sign in to comment.