Skip to content

Commit

Permalink
feat: Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed May 12, 2024
1 parent dbe39fa commit c751a6e
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab
17 changes: 17 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 💥
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features ✨
labels:
- Semver-Minor
- enhancement
- title: Bug Fixes 🐛
labels:
- Semver-Patch
- bug
23 changes: 23 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up env
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Make release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release:
./scripts/release.sh
36 changes: 36 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

if [ -z "$VERSION" ]; then echo "Error: VERSION is not set"; exit 1; fi

GH_TAG="v$VERSION"

set_release_action() {
if gh release view "$GH_TAG" --json id --jq .id > /dev/null 2>&1; then
echo "Release $GH_TAG already exists, replace it"
RELEASE_ACTION="replace"
else
echo "Release $GH_TAG does not exist, creating it"
RELEASE_ACTION="create"
fi
}

do_gh_release() {
if [ "$RELEASE_ACTION" == "replace" ]; then
echo "Replacing existing release $GH_TAG"
gh release delete "$GH_TAG"
else
echo "Creating new release $GH_TAG"
fi
gh release create --generate-notes "$GH_TAG"
}

release() {
set_release_action
do_gh_release
}

boot() {
release
}

boot

0 comments on commit c751a6e

Please sign in to comment.