-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: added workflows for conventional commits and semantic versioning
- Loading branch information
1 parent
8b51208
commit a5d73e7
Showing
5 changed files
with
233 additions
and
0 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,37 @@ | ||
name: 🔎 Conventional Commit Checks | ||
run-name: 🔎 Checking conventional commit on ${{ github.sha }} | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
- '!main' | ||
|
||
|
||
jobs: | ||
conventional-commit-check: | ||
runs-on: ubuntu-latest | ||
name: Conventional Commit Check | ||
steps: | ||
|
||
# check out repository | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
fetch-depth: 0 | ||
|
||
# install cargo | ||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
# install convco | ||
- name: Install convco | ||
run: cargo install cocogitto --locked | ||
|
||
# check for conventional commits | ||
- name: Check for conventional commits | ||
run: scripts/devops/conv-commit-check |
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,47 @@ | ||
name: 🏗️ Build Tag | ||
run-name: 🏗️ Building Tag ${{ github.ref_name }} | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]*.[0-9]*.[0-9]*' | ||
|
||
jobs: | ||
application-tests: | ||
name: Application Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
|
||
application-build: | ||
name: Application Build | ||
needs: [ application-tests ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
|
||
container-build: | ||
name: Container Build | ||
runs-on: ubuntu-latest | ||
needs: [ application-build ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
|
||
push-artifacts: | ||
name: Push Artifacts | ||
runs-on: ubuntu-latest | ||
needs: [ application-build, container-build ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} |
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,63 @@ | ||
name: 🏷️ Tag Semantic Version | ||
run-name: ${{ (github.event.inputs.dry_run == 'true') && '🏷️ Tagging new semantic version [DRY RUN]' || '🏷️ Tagging new semantic version' }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
bump_type: | ||
description: "The type of bump to perform" | ||
type: choice | ||
options: | ||
- auto | ||
- patch | ||
- minor | ||
- major | ||
required: false | ||
default: auto | ||
dry_run: | ||
description: "Run semantic-release in dry-run mode" | ||
type: choice | ||
options: | ||
- true | ||
- false | ||
required: false | ||
default: 'true' | ||
|
||
jobs: | ||
tag-semantic-version: | ||
runs-on: ubuntu-latest | ||
name: New Semantic Version | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Install Cocogitto | ||
run: | | ||
cargo install cocogitto --locked | ||
cargo install cargo-edit --locked | ||
- name: Configure Git | ||
run: | | ||
git config --global user.name "Infrastructure[bot]" | ||
git config --global user.email "infrastructure@movementlabs.xyz" | ||
- name: Pull tags | ||
run: | | ||
git fetch --tags | ||
- name: Bump Version | ||
run: | | ||
./scripts/devops/tag-semantic-release ${{ inputs.bump_type }} ${{ inputs.dry_run }} | ||
- name: Push commit and tags | ||
run: | | ||
git push | ||
git push --tags |
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,29 @@ | ||
#!/bin/bash | ||
|
||
# check if git is installed | ||
if ! command -v git &> /dev/null; then | ||
echo "git is not installed" | ||
exit 1 | ||
fi | ||
|
||
# check if cog is installed | ||
if ! command -v cog &> /dev/null; then | ||
echo "cocogitto (cog) is not installed" | ||
exit 1 | ||
fi | ||
|
||
echo "Checking for conventional commits" | ||
|
||
# get current commit hash | ||
COMMIT_HASH_CURRENT=$(git rev-parse HEAD) | ||
|
||
# check for conventional commits | ||
CONVENTIONAL_COMMITS=$(cog check) | ||
|
||
if echo "$CONVENTIONAL_COMMITS" | grep -qi "Error:"; then | ||
echo "Failures found in conventional commit" | ||
exit 1 | ||
fi | ||
|
||
exit 0 | ||
|
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,57 @@ | ||
#!/bin/bash | ||
|
||
# parse bump type from args | ||
BUMP_TYPE=${1:-auto} | ||
if [ "$BUMP_TYPE" != "auto" ] && [ "$BUMP_TYPE" != "major" ] && [ "$BUMP_TYPE" != "minor" ] && [ "$BUMP_TYPE" != "patch" ]; then | ||
echo "Invalid bump type: $BUMP_TYPE" | ||
exit 1 | ||
fi | ||
|
||
# parse dry run from args | ||
DRY_RUN=${2:-true} | ||
|
||
# format dry run | ||
if [ "$DRY_RUN" == "true" ]; then | ||
DRY_RUN="--dry-run" | ||
else | ||
DRY_RUN="" | ||
fi | ||
|
||
# check if git is installed | ||
if ! command -v git &> /dev/null; then | ||
echo "git is not installed" | ||
exit 1 | ||
fi | ||
|
||
# check if cog is installed | ||
if ! command -v cog &> /dev/null; then | ||
echo "cocogitto (cog) is not installed" | ||
exit 1 | ||
fi | ||
|
||
# check if cargo-edit is installed | ||
if ! cargo install --list | grep -q "cargo-edit"; then | ||
echo "cargo-edit is not installed" | ||
exit 1 | ||
fi | ||
|
||
echo "Creating semantic release" | ||
|
||
# check for conventional commits | ||
CONVENTIONAL_COMMITS=$(cog check) | ||
|
||
if echo "$CONVENTIONAL_COMMITS" | grep -qi "Error:"; then | ||
echo "Failures found in conventional commit" | ||
exit 1 | ||
fi | ||
|
||
# bump version | ||
echo "Bumping version" | ||
cog bump --$BUMP_TYPE $DRY_RUN | ||
|
||
# output the new version | ||
NEW_VERSION=$(cog get-version) | ||
NEW_VERSION="${NEW_VERSION#New version: }" | ||
echo "$NEW_VERSION" | ||
|
||
exit 0 |