-
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.
ci(.github/workflows): Add Tag and Release workflow
- Loading branch information
Showing
1 changed file
with
112 additions
and
0 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,112 @@ | ||
name: Tag and Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
BINARY_NAME: "prettylogs" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.23.3' | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Test | ||
run: make test | ||
|
||
build: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
targets: | ||
- name: "macos" | ||
cmd: make build-macos | ||
artifact: "wave1_darwin" | ||
- name: "macos-apple-silicon" | ||
cmd: make build-macos-arm | ||
artifact: "wave1_apple_silicon" | ||
- name: "linux-amd64" | ||
cmd: make build-linux | ||
artifact: "wave1_linux_amd64" | ||
- name: "linux-arm64" | ||
cmd: make build-linux-arm | ||
artifact: "wave1_linux_arm64" | ||
- name: "windows" | ||
cmd: make build-windows | ||
artifact: "wave1_windows.exe" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.23.3' | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Build ${{ matrix.targets.name }} | ||
run: ${{ matrix.targets.cmd }} | ||
|
||
- name: Upload Build Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.targets.name }} | ||
path: "bin/${{ matrix.targets.artifact }}" | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Download all artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: artifacts | ||
|
||
- name: Generate Release Body | ||
id: release_body | ||
run: | | ||
echo "body<<EOF" >> $GITHUB_OUTPUT | ||
echo "Changelog:" >> $GITHUB_OUTPUT | ||
git log $(git describe --tags --abbrev=0)..HEAD --oneline >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Create Release and Upload Assets | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
token: ${{ secrets.GH_PERSONAL_TOKEN }} | ||
name: Release ${{ github.ref_name }} | ||
body: ${{ steps.release_body.outputs.body }} | ||
files: artifacts/**/* |