-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(actions): release and build workflows (#2)
* chore(teamlog): add team logs endpoint; auth db query fn * chore(teamlog): add selectable team db menu * chore(teamlog): minor style changes * chore(semvar): add cocogitto config * chore(gitflow): build release ci yml; cog init * chore(gitflow): build release yml * chore(semver): cocogitto config file * chore(cog): adjust cocogitto config * chore(cog): mod release ci yml; add dev docs * chore(cog): mod release ci yml; add dev docs * chore(docs): add dev docs * chore(docs): add dev docs * chore(ci): fix release yml
- Loading branch information
Showing
10 changed files
with
329 additions
and
43 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,54 @@ | ||
# release ci: build linux binaries and attach to release with SHA256 | ||
|
||
name: build | ||
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [ published ] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
|
||
build: | ||
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }} | ||
runs-on: ${{ matrix.platform.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- os_name: Linux-aarch64 | ||
os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-musl | ||
bin: cerebro-${{ github.event.release.tag_name }}-linux-arm64 # semver release tag | ||
- os_name: Linux-x86_64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-gnu | ||
bin: cerebro-${{ github.event.release.tag_name }}-linux-amd64 # semver release tag | ||
toolchain: | ||
- stable | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build binary | ||
uses: houseabsolute/actions-rust-cross@v0 | ||
with: | ||
command: "build" | ||
target: ${{ matrix.platform.target }} | ||
toolchain: ${{ matrix.toolchain }} | ||
args: "--locked --release" | ||
strip: true | ||
- name: Rename binary (linux and macos) | ||
run: mv target/${{ matrix.platform.target }}/release/cerebro target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | ||
if: matrix.platform.os_name != 'Windows-x86_64' | ||
- name: Generate SHA-256 of uncompressed binary | ||
run: shasum -a 256 target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | cut -d ' ' -f 1 > target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.sha256 | ||
- name: Compress binary | ||
run: tar -cJf target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.tar.xz target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | ||
- name: Release binary and SHA-256 checksum to GitHub | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.tar.xz | ||
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.sha256 |
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,43 @@ | ||
# release ci: create cocogitto semantic version release + changelog, enforce conventional commit compliance | ||
# executed when a pr is made on main which pulls in a release branch (deriving from main and dev fetch) | ||
# triggers build yml when release is published, which attaches `latest` and {version} tagged release builds and sha256 checksums | ||
|
||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
branches: main | ||
|
||
jobs: | ||
release: | ||
name: Perform release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Conventional commits check | ||
uses: oknozor/cocogitto-action@v3 | ||
with: | ||
check-latest-tag-only: true | ||
|
||
- name: Cocogitto release | ||
id: release | ||
uses: oknozor/cocogitto-action@v3 | ||
with: | ||
release: true | ||
git-user: ${{ secrets.GIT_USER }} | ||
git-user-email: ${{ secrets.GIT_EMAIL }} | ||
|
||
- name: Generate Changelog | ||
run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md | ||
|
||
- name: Upload github release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body_path: GITHUB_CHANGELOG.md | ||
tag_name: ${{ steps.release.outputs.version }} | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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
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
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
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,36 @@ | ||
skip_untracked = false | ||
from_latest_tag = false | ||
ignore_merge_commits = true | ||
generate_mono_repository_global_tag = true | ||
|
||
# cog bumps can only be made on main or release branches | ||
branch_whitelist = [ | ||
"main", | ||
"release/**" | ||
] | ||
|
||
# before the version is bumped | ||
# build the release binary on local as check | ||
# set the cargo project version to this release version | ||
pre_bump_hooks = [ | ||
"cargo build --release", | ||
"echo 'bumping from {{latest}} to {{version}}'", | ||
"cargo set-version {{version}}" | ||
] | ||
|
||
post_bump_hooks = [] | ||
|
||
pre_package_bump_hooks = [] | ||
post_package_bump_hooks = [] | ||
|
||
[git_hooks] | ||
|
||
[commit_types] | ||
|
||
[changelog] | ||
path = "CHANGELOG.md" | ||
authors = [] | ||
|
||
[bump_profiles] | ||
|
||
[packages] |
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,94 @@ | ||
# Development | ||
|
||
Development setup: | ||
|
||
* `Docker` and `docker compose` | ||
* `rust >= v1.72` with `cargo-watch`, `cargo fmt`, `cargo clippy` | ||
* `cocogitto >= v1.2.1` for convenvional commits and semantic version releases via `cog commit {feat} "{msg}" {scope}` command-line drop-in for `git commit` | ||
|
||
Commits must use `cog commit` or manual conventional commit style - these can be squashed or rebased for a single merge commit into `dev` from the conventional commit named branch for example `feat/new_feature` or `chore/docs`. Pull requests only into `dev` never `main`. Release commits on `main` pull changes from `dev` via a `release/{version}` branc. Release action triggers the `cog bump --auto` changelog and version bump with cross compilation pipelines that attach Linux binaries on release publication. | ||
|
||
## Setup dev environment | ||
|
||
```bash | ||
# get latest cerebro bin for deployment | ||
curl https://github.com/esteinig/cerebro/releases/download/latest/cerebro-latest-Linux_x86_64.tar.xz -o - | tar -xzO > cerebro | ||
|
||
# clone repo to track state | ||
git clone https://github.com/esteinig/cerebro.git@latest | ||
|
||
# docker prefix for this deployment | ||
CEREBRO_PREFIX="dev_local" | ||
|
||
# link deployment to the git repo and | ||
# deploy on `dev_local` docker prefix | ||
# with a `dev.cerebro.localhost` domain | ||
# via the contained traefik reverse proxy | ||
cerebro deploy \ | ||
--dev ${pwd}/cerebro | ||
--config local.toml \ | ||
--docker-prefix $CEREBRO_PREFIX \ | ||
--outdir dev_local/ \ | ||
--http # traefik rev proxy for http://{api,app}.dev.cerebro.localhost/ | ||
--http-domain "dev.cerebro.localhost" | ||
|
||
# enter deployment and up the stack | ||
cd dev_local/ && docker compose up | ||
|
||
# changes to the app ui are reflected immediately due to node dev server | ||
# changes to the rust codebase require rebuild of the app e.g. when changing api code | ||
|
||
# [TBD] fmt and clippy hooks are executed for rust changes | ||
|
||
# down the containter stack and remove the stopped containers - this is recommended | ||
# as a local reverse proxy can return docker network errors and db connections can fail | ||
docker compose down && docker container rm $(docker ps --format "{{.Names}}" | grep "$CEREBRO_PREFIX"-) | ||
|
||
# build flag triggers rebuild of changed components in the docker compose file | ||
docker compose up --build | ||
|
||
# checkout current feat branch and commit changes | ||
git checkout feat/new_feature | ||
cog commit chore "minor changes to auth api" auth | ||
git push origin feat/new_feature | ||
|
||
# create new pr with conventional commit style | ||
# to merge feat/new_feature into dev | ||
|
||
# squash working commits on pr into dev to | ||
# the primary conventional commit | ||
# | ||
# docs/readme branch -> dev | ||
# readme(docs): dev section draft | ||
# | ||
# dev pr squash commits are published in main release changelog | ||
``` | ||
|
||
## Git progression for release | ||
|
||
```bash | ||
# checkout latest main | ||
git checkout main | ||
|
||
# pull latest dev into main and run auto changelog | ||
git fetch dev | ||
|
||
# checkout auto changelog for version release | ||
cog changelog --auto | ||
|
||
# get update version | ||
$RELEASE_VERSION=$(cog bump --dry-run --auto) | ||
|
||
# checkout version release branch | ||
git checkout -b release/$RELEASE_VERSION | ||
|
||
# cog commit release chore to version | ||
git add . && cog commit chore "$RELEASE_VERSION" release | ||
|
||
# push to remote to trigger release and build actions | ||
git push origin release/$RELEASE_VERSION | ||
|
||
# create pr of `release/$RELEASE_VERSION` into 'main' | ||
# release with latest changelog and binaries is created on ci/cd | ||
|
||
``` |
Oops, something went wrong.