Skip to content

Commit

Permalink
feature/1220 origin handle exists method (#1243)
Browse files Browse the repository at this point in the history
* 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

---------

Signed-off-by: Prad Nukala <prad@sonr.io>
Co-authored-by: Darp Alakun <i@prad.nu>
  • Loading branch information
prnk28 and prdnk authored Jan 6, 2025
1 parent 2f65b1c commit fe7c747
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .cz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
64 changes: 14 additions & 50 deletions .github/workflows/checks.yml → .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
name: Perform Checks on PR
name: Check PR

on:
pull_request:
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:
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
Expand All @@ -31,7 +30,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
Expand All @@ -50,7 +49,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
Expand All @@ -65,47 +64,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 Release
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -119,20 +81,22 @@ 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
- name: GoReleaser Test
run: make release-dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/merge-group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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

validate-tag:
runs-on: ubuntu-latest
name: Validate Tag
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: Commitizen Dry Run
id: cz
uses: commitizen-tools/commitizen-action@master
with:
push: false
dry_run: true
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main

- name: Check if tag exists
run: |
DETERMINED_VERSION="${{ steps.cz.outputs.version }}"
if git ls-remote --tags origin "refs/tags/v${DETERMINED_VERSION}" | grep -q .; then
echo "::error::Tag v${DETERMINED_VERSION} already exists upstream"
exit 1
fi
echo "Tag v${DETERMINED_VERSION} does not exist - OK to proceed"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bump Version on Merge
name: Post Merge
on:
pull_request:
types: [closed]
Expand All @@ -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]' &&
Expand All @@ -26,6 +27,7 @@ jobs:
with:
push: false
increment: patch
branch: main

- name: Push using ssh
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Assets on Release
name: New Release
on:
release:
types: [published]
Expand All @@ -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`
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Versioned Release
name: New Tag

on:
pull_request:
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
###############################################################################
Expand Down
54 changes: 6 additions & 48 deletions scripts/setup_env.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 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 get_deps() {
function main() {
go_install go-task/task/v3/cmd/task@latest
go_install x-motemen/ghq@latest
go_install a-h/templ/cmd/templ@latest
go_install goreleaser/goreleaser/v2@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 main() {
get_deps
set_git
gh_ext_install johnmanjiro13/gh-bump
}

main
Loading

0 comments on commit fe7c747

Please sign in to comment.