Skip to content

Commit

Permalink
ci: Add semantic release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AzHicham committed Dec 10, 2023
1 parent 14b7cab commit 9046a2b
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .github/scripts/edit-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

# This script is used to edit the version in versions files

echo "Editing files with given version: $1";

# Edit Cargo.toml
semantic-release-cargo prepare "$1"
8 changes: 6 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Benchmarks

on:
push:
branches: [ main ]
branches:
- main
- develop
pull_request:
branches: [ main ]
branches:
- main
- develop

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Clippy checks

on:
push:
branches: [ main ]
branches:
- develop

env:
CARGO_TERM_COLOR: always
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: Coverage

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
branches:
- main
- develop

env:
CARGO_TERM_COLOR: always
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
workflow_dispatch: # only for release on develop branch
push:
branches:
- main
- rc
- experimental
- "[0-9]+.[0-9]+.x"
- "[0-9]+.x"

# Only allow one release workflow to execute at a time, since each release
# workflow uses shared resources (git tags, package registries)
concurrency:
group: ${{ github.workflow }}

jobs:
release:
runs-on: ubuntu-22.04
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # Semantic release need use SCOPED_GITHUB_TOKEN to create release

- name: Install semantic-release-cargo
uses: EricCrosson/install-github-release-binary@v2
with:
targets: semantic-release-cargo/semantic-release-cargo@v2.2.30

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.SCOPED_GITHUB_TOKEN }}
with:
semantic_version: 22.0.6
extra_plugins: |
@semantic-release/changelog@6.0.3
@semantic-release/git@10.0.1
@semantic-release/exec@6.0.3
conventional-changelog-conventionalcommits@7.0.2
@saithodev/semantic-release-backmerge@3.2.1
5 changes: 3 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
schedule:
- cron: "0 0 * * 1,5"
push:
branches: [ main ]
branches:
- main
- develop
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always
Expand Down
84 changes: 84 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"tagFormat": "${version}",
"branches": [
"main",
{
"name": "rc",
"prerelease": true
},
{
"name": "develop",
"prerelease": "dev"
},
{
"name": "experimental",
"prerelease": "exp"
},
"+([0-9])?(.{+([0-9]),x}).x"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{ "type": "perf", "scope": "*", "release": "patch" },
{ "type": "chore", "scope": "*", "release": "patch" },
{ "type": "refactor", "scope": "*", "release": "patch" }
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{ "type": "feat", "section": "Features" },
{ "type": "fix", "section": "Bug Fixes" },
{ "type": "perf", "section": "Performance Improvements" },
{ "type": "revert", "section": "Reverts" },
{ "type": "docs", "section": "Documentation" },
{ "type": "ci", "section": "CI/CD", "hidden": false },
{ "type": "chore", "section": "Miscellaneous Chores", "hidden": false },
{ "type": "style", "section": "Styles", "hidden": true },
{ "type": "refactor", "section": "Code Refactoring", "hidden": true },
{ "type": "test", "section": "Tests", "hidden": true },
{ "type": "build", "section": "Build System", "hidden": true }
]
}
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "./.github/scripts/edit-version.sh ${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"Cargo.toml",
"Cargo.lock"
],
"message": "chore(release): ${nextRelease.version}\n\n[skip ci]"
}
],
"@semantic-release/github",
[
"@saithodev/semantic-release-backmerge",
{
"backmergeBranches": [{"from": "main", "to": "develop"}],
"fastForwardMode": "ff"
}
]
]
}

0 comments on commit 9046a2b

Please sign in to comment.