feature/1220 origin handle exists method (#1243)

* feat: add docs and CI workflow for publishing to onsonr.dev

* (refactor): Move hway,motr executables to their own repos

* feat: simplify devnet and testnet configurations

* refactor: update import path for didcrypto package

* docs(networks): Add README with project overview, architecture, and community links

* refactor: Move network configurations to deploy directory

* build: update golang version to 1.23

* refactor: move logger interface to appropriate package

* refactor: Move devnet configuration to networks/devnet

* chore: improve release process with date variable

* (chore): Move Crypto Library

* refactor: improve code structure and readability in DID module

* feat: integrate Trunk CI checks

* ci: optimize CI workflow by removing redundant build jobs

* feat: integrate Trunk CI checks, simplify devnet and testnet configurations, add docs and CI for onsonr.dev publishing, automate releases using Taskfile and GitHub Actions, and add Reddit release notification

* ci: Trigger release validation on pull requests

* ci: Migrate GoReleaser configuration to Makefiles

* chore: update CI workflow permissions and rename job

* refactor: remove unnecessary docker push steps from release process

* feat: automate release process using Taskfile and GitHub Actions

* fix: change shebang from bash to sh

* chore: update setup script shebang to bash

* chore: remove unnecessary setup-env step from release process

* test: improve test descriptions and naming for clarity

* refactor: rename workflow files for clarity

* refactor: rename post-merge workflow file

* refactor: Move race and coverage tests to separate workflow

* refactor: simplify merge group trigger

* chore: prevent accidental release overwriting of existing tags

* test: rename GoReleaser Dry Run step to GoReleaser Test

* fix: correct GitHub Actions workflow for version bumping

* fix: Correct tag validation in CI workflow

* refactor: simplify GitHub Actions workflow for version checking

* test: replace version check with make command

* chore: update setup-python action to v5

* test: rename workflow job and remove unnecessary steps

* feat: enable workflow on merge group events

---------

Signed-off-by: Prad Nukala <prad@sonr.io>
Co-authored-by: Darp Alakun <i@prad.nu>
This commit is contained in:
Prad Nukala 2025-01-06 14:00:11 -05:00 committed by GitHub
parent 2f65b1c283
commit 7f3aa01bd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 154 additions and 115 deletions

View File

@ -3,6 +3,6 @@ name = "cz_conventional_commits"
tag_format = "v$version"
version_scheme = "semver"
version = "0.6.1"
update_changelog_on_bump = false
update_changelog_on_bump = true
major_version_zero = true
changelog_file = "CHANGELOG.md"

View File

@ -1,4 +1,4 @@
name: Perform Checks on PR
name: Check PR
on:
pull_request:
@ -10,7 +10,7 @@ permissions:
jobs:
verify-pr:
name: Verify PR
name: Test Lints
if: github.event_name == 'pull_request'
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
@ -31,7 +31,7 @@ jobs:
test-builds:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Run Build Tests
name: Test Builds
steps:
- name: Checkout repository
uses: actions/checkout@v4
@ -50,7 +50,7 @@ jobs:
test-unit:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Run Unit Tests
name: Test Unit
steps:
- name: Checkout repository
uses: actions/checkout@v4
@ -65,47 +65,10 @@ jobs:
check-latest: true
- run: make test-unit
test-race:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Run Race Tests
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-race
test-cover:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Run Coverage Tests
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-cover
validate-release:
if: github.event_name == 'merge_group' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Verify Release Config
name: Test Version
steps:
- name: Checkout repository
uses: actions/checkout@v4
@ -119,20 +82,17 @@ jobs:
go-version: "1.23"
check-latest: true
- name: Commitizen Dry Run
uses: commitizen-tools/commitizen-action@master
- name: Install Python
uses: actions/setup-python@v5
with:
push: false
dry_run: true
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
python-version: "3.x"
- name: Version Check
run: make validate-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check GoReleaser Config
run: make release-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: GoReleaser Dry Run
run: make release-dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

68
.github/workflows/merge-group.yml vendored Normal file
View File

@ -0,0 +1,68 @@
name: Merge Group
on:
merge_group:
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
jobs:
test-race:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Test Race
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-race
test-cover:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Test Coverage
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-cover
test-release:
runs-on: ubuntu-latest
name: Test Release
if: github.event_name == 'merge_group'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- name: Release Dry Run
run: make release-dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,4 +1,4 @@
name: Bump Version on Merge
name: Post Merge
on:
pull_request:
types: [closed]
@ -9,6 +9,7 @@ permissions:
jobs:
bump-version:
name: Cz Bump
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
@ -26,6 +27,7 @@ jobs:
with:
push: false
increment: patch
branch: main
- name: Push using ssh
run: |

View File

@ -1,4 +1,4 @@
name: Publish Assets on Release
name: New Release
on:
release:
types: [published]
@ -9,7 +9,7 @@ permissions:
jobs:
buf_push:
name: Publish to buf.build/onsonr/sonr
name: Publish Protobufs
runs-on: ubuntu-latest
steps:
# Run `git checkout`
@ -24,7 +24,7 @@ jobs:
buf_token: ${{ secrets.BUF_TOKEN }}
container-push:
name: Publish Container Images
name: Publish Docker Images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -45,7 +45,7 @@ jobs:
docs-push:
runs-on: ubuntu-latest
name: Publish Docs to onsonr.dev
name: Publish Tech Docs
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials

View File

@ -1,4 +1,4 @@
name: Versioned Release
name: New Tag
on:
pull_request:
@ -14,7 +14,7 @@ permissions:
jobs:
new-release:
name: Run GoReleaser on New Tag
name: Create Release
if: startsWith(github.ref, 'refs/tags/')
permissions: write-all
runs-on: ubuntu-latest

View File

@ -5,10 +5,6 @@ project_name: sonr
before:
hooks:
- echo "Release date is {{ .Env.RELEASE_DATE }}"
- docker build -t ghcr.io/onsonr/sonr:latest .
- docker tag ghcr.io/onsonr/sonr:latest ghcr.io/onsonr/sonr:{{ .Tag }}
- docker push ghcr.io/onsonr/sonr:{{ .Tag }}
- docker push ghcr.io/onsonr/sonr:latest
builds:
- id: sonr

View File

@ -342,6 +342,8 @@ release-check:
@go install github.com/goreleaser/goreleaser/v2@latest
@RELEASE_DATE=$(RELEASE_DATE) goreleaser check
validate-tag:
@sh ./scripts/validate_tag.sh
###############################################################################
### help ###
###############################################################################

View File

@ -1,7 +1,5 @@
#!/bin/bash
set -e
ROOT_DIR=$(git rev-parse --show-toplevel)
# Function to install a Go binary if it doesn't exist
@ -12,57 +10,17 @@ function go_install() {
fi
}
# Function to install a Cargo binary if it doesn't exist
function cargo_install() {
if ! command -v "$1" &>/dev/null; then
echo "Installing $1..."
cargo install "$1"
fi
}
# Function to install a uv tool if it doesn't exist
function uv_install() {
if ! command -v "$1" &>/dev/null; then
echo "Installing $1..."
uv tool install "$1" --force
fi
}
# Function to initialize git credentials
function set_git() {
git config --global user.name "Darp Alakun"
git config --global user.email "i@prad.nu"
# Check if the GITHUB_TOKEN is set then authenticate with it if not ignore
if [[ -z ${GITHUB_TOKEN} ]]; then
echo "GITHUB_TOKEN is not set. Please set it before running this script."
exit 1
else
gh auth login --with-token <<<"${GITHUB_TOKEN}"
fi
}
function get_deps() {
go_install go-task/task/v3/cmd/task@latest
go_install x-motemen/ghq@latest
go_install a-h/templ/cmd/templ@latest
cargo_install ripgrep
cargo_install fd-find
cargo_install eza
uv_install aider-chat
}
function clone_repos() {
ghq get github.com/onsonr/sonr
ghq get github.com/onsonr/nebula
ghq get github.com/onsonr/hway
# Function to install a gh extension if it doesn't exist. Check gh <extension> for checking if installed
function gh_ext_install() {
gh extension install "$1"
}
function main() {
get_deps
set_git
go_install go-task/task/v3/cmd/task@latest
go_install a-h/templ/cmd/templ@latest
go_install goreleaser/goreleaser/v2@latest
gh_ext_install johnmanjiro13/gh-bump
}
main

53
scripts/validate_tag.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
set -e # Exit on any error
# Function to compare version strings
version_gt() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"
}
# Install commitizen if not present
if ! command -v cz &> /dev/null; then
echo "Installing commitizen..."
pip install --user commitizen
fi
# Get all tags and sort them by version
echo "Fetching all tags..."
git fetch --tags --force
TAGS=$(git tag -l "v*" | sort -V)
LATEST_TAG=$(echo "$TAGS" | tail -n1)
if [ -z "$LATEST_TAG" ]; then
echo "No tags found"
exit 1
fi
echo "Latest tag: $LATEST_TAG"
# Run commitizen to determine next version
echo "Running commitizen bump --dry-run..."
NEXT_VERSION=$(cz bump --dry-run --increment=patch 2>&1 | grep "tag to create: v" | cut -d "v" -f2)
if [ -z "$NEXT_VERSION" ]; then
echo "Failed to determine next version"
exit 1
fi
echo "Next version determined by commitizen: v$NEXT_VERSION"
# Check if the next version already exists
if echo "$TAGS" | grep -q "v$NEXT_VERSION"; then
echo "ERROR: Version v$NEXT_VERSION already exists!"
exit 1
fi
# Verify the next version is actually greater than the latest
if ! version_gt "$NEXT_VERSION" "${LATEST_TAG#v}"; then
echo "ERROR: Next version v$NEXT_VERSION is not greater than current version $LATEST_TAG"
exit 1
fi
echo "✅ Version v$NEXT_VERSION is valid and does not exist yet"
exit 0