diff --git a/.github/workflows/checks-conventional-commits.yml b/.github/workflows/checks-conventional-commits.yml new file mode 100644 index 000000000..3dfd61ae4 --- /dev/null +++ b/.github/workflows/checks-conventional-commits.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/tag-build.yml b/.github/workflows/tag-build.yml new file mode 100644 index 000000000..65a24519d --- /dev/null +++ b/.github/workflows/tag-build.yml @@ -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 }} diff --git a/.github/workflows/tag-semantic-version.yml b/.github/workflows/tag-semantic-version.yml new file mode 100644 index 000000000..7bc8f942c --- /dev/null +++ b/.github/workflows/tag-semantic-version.yml @@ -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 diff --git a/scripts/devops/conv-commit-check b/scripts/devops/conv-commit-check new file mode 100755 index 000000000..3cf50187f --- /dev/null +++ b/scripts/devops/conv-commit-check @@ -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 + diff --git a/scripts/devops/tag-semantic-release b/scripts/devops/tag-semantic-release new file mode 100755 index 000000000..01feb1202 --- /dev/null +++ b/scripts/devops/tag-semantic-release @@ -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