Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Build binaries and automatically create release on Tag creation #47

Merged
merged 33 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
52eba13
chore: updated linter version
mrz1836 Feb 10, 2024
f75a66a
chore: upgraded deps
mrz1836 Feb 10, 2024
b868401
fix: linter issues after upgrading
mrz1836 Feb 10, 2024
e8f8ff0
feat: build binaries on release, adding tag
mrz1836 Feb 10, 2024
93415a0
fix: install cross compilation for ARM64
mrz1836 Feb 10, 2024
9fdaa57
fix: add new flags for compilation
mrz1836 Feb 10, 2024
bec1c43
fix: turn off arm64 for testing
mrz1836 Feb 10, 2024
c2a712f
fix: trying another version of build configurations
mrz1836 Feb 10, 2024
b4b6678
fix: replaced name, need to test
mrz1836 Feb 10, 2024
ee4ee57
chore: minor formatting and spelling fix
mrz1836 Feb 10, 2024
8e51c7d
fix: for windows path, suggestion from copilot
mrz1836 Feb 10, 2024
49f0b5d
fix: attempt to build with cgo enabled
mrz1836 Feb 10, 2024
553706d
fix: adding cache to speed up runs
mrz1836 Feb 10, 2024
14a65c8
fix: removing additional vars
mrz1836 Feb 10, 2024
7b99a4e
test: working on linux only release
mrz1836 Feb 10, 2024
2054075
fix: for yaml linter
mrz1836 Feb 10, 2024
897cb35
fix: file extension does not match
mrz1836 Feb 10, 2024
67e4489
fix: names, tags, deprecated fields
mrz1836 Feb 10, 2024
b6d153b
fix: add changelog and checksums
mrz1836 Feb 10, 2024
8dbc255
feat: added darwin binary
mrz1836 Feb 10, 2024
8409cc2
fix: for removing gcc from darwin
mrz1836 Feb 10, 2024
d80f51e
fix: attempt to fix a perm issue on installing golangci
mrz1836 Feb 10, 2024
49bab17
fix: add more logging to lint install
mrz1836 Feb 10, 2024
2ccce9f
fix: set the gopath env
mrz1836 Feb 10, 2024
1d42ad7
fix: attempt to overwrite go if detected
mrz1836 Feb 10, 2024
07690ea
fix: working on safer brew execution
mrz1836 Feb 10, 2024
5023bd6
fix: only run one install
mrz1836 Feb 10, 2024
4db9168
chore: cleanup of files
mrz1836 Feb 10, 2024
cb0b471
chore: cleanup old code
mrz1836 Feb 10, 2024
96051bd
fix: added more timeout to linting
mrz1836 Feb 10, 2024
b2e70b9
fix: only install if needed
mrz1836 Feb 10, 2024
6fa8eae
fix: improved lint function
mrz1836 Feb 10, 2024
d7852ea
fix: make the ids unique
mrz1836 Feb 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 109 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: release

env:
GO111MODULE: on
GO_VERSION: 1.21

on:
push:
Expand All @@ -13,24 +14,125 @@ permissions:
contents: write

jobs:
goreleaser:
build-linux-binary:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: gcc install
run: sudo apt-get update; sudo apt install gcc-aarch64-linux-gnu
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: ${{ env.GO_VERSION }}
- name: Cache code
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
"%LocalAppData%\\go-build" # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5.0.0
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --clean --debug
args: release --skip=publish --verbose --config .goreleaser-for-linux.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#- name: Syndicate to GoDocs
# run: make godocs
- name: Upload
uses: actions/upload-artifact@v4
with:
name: alert_system_linux
path: |
dist/alert_system_*.zip
dist/checksums.txt
dist/CHANGELOG.md

build-darwin-binary:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache code
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
"%LocalAppData%\\go-build" # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --skip=publish --verbose --config .goreleaser-for-darwin.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: alert_system_darwin
path: |
dist/alert_system_*.zip
dist/checksums.txt
dist/CHANGELOG.md

create-release:
needs: [build-linux-binary, build-darwin-binary]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Make directories
run: |
mkdir -p ./dist/linux
mkdir -p ./dist/darwin
mkdir -p ./dist/windows
- name: Download linux binaries
uses: actions/download-artifact@v4
with:
name: alert_system_linux
path: ./tmp-build/linux
- name: Download darwin binaries
uses: actions/download-artifact@v4
with:
name: alert_system_darwin
path: ./tmp-build/darwin
- name: Get tag
uses: little-core-labs/get-git-tag@v3.0.2
id: tag
- name: Prepare ./dist folder
run: |
mkdir -p ./dist
mv ./tmp-build/linux/*.zip ./dist
mv ./tmp-build/darwin/*.zip ./dist
cat ./tmp-build/linux/checksums.txt >> ./dist/checksums.txt
cat ./tmp-build/linux/CHANGELOG.md >> ./dist/CHANGELOG.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: dist/CHANGELOG.md
prerelease: ${{ contains(github.ref, '-rc.') }}
files: |
dist/*.zip
dist/CHANGELOG.md
env:
COMMIT_TAG: ${{steps.tag.outputs.tag}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows)
"%LocalAppData%\\go-build" # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 6m
timeout: 10m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand Down
56 changes: 56 additions & 0 deletions .goreleaser-for-darwin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Make sure to check the documentation at http://goreleaser.com
# ---------------------------
# General
# ---------------------------
before:
hooks:
- make all
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^.github:'
- '^.vscode:'
- '^docs:'
- '^test:'

# ---------------------------
# Builder
#
# CGO is enabled and inspiration came from:
# https://github.com/goreleaser/goreleaser-cross-example
# https://github.com/goreleaser/goreleaser-cross-example-sysroot
# https://github.com/DataDog/extendeddaemonset/blob/main/.goreleaser-for-darwin.yaml
# ---------------------------
builds:
- id: darwin-build
main: ./cmd/
binary: alert_system
goos:
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=1
mod_timestamp: "{{ .CommitTimestamp }}"
ldflags:
- -s -w -X main.version={{.Version}}

# ---------------------------
# Archives + Checksums
# ---------------------------
archives:
- id: alert_system_darwin
builds:
- darwin-build
name_template: "alert_system_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: false
format: zip
files:
- LICENSE
checksum:
name_template: "checksums.txt"
algorithm: sha256
61 changes: 61 additions & 0 deletions .goreleaser-for-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Make sure to check the documentation at http://goreleaser.com
# ---------------------------
# General
# ---------------------------
before:
hooks:
- make all
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^.github:'
- '^.vscode:'
- '^docs:'
- '^test:'

# ---------------------------
# Builder
#
# CGO is enabled and inspiration came from:
# https://github.com/goreleaser/goreleaser-cross-example
# https://github.com/goreleaser/goreleaser-cross-example-sysroot
# https://github.com/DataDog/extendeddaemonset/blob/main/.goreleaser-for-linux.yaml
# ---------------------------
builds:
- id: linux-build
main: ./cmd/
binary: alert_system
goos:
- linux
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=1
mod_timestamp: "{{ .CommitTimestamp }}"
ldflags:
- -s -w -X main.version={{.Version}}
overrides:
- goos: linux
goarch: arm64
env:
- CC=aarch64-linux-gnu-gcc

# ---------------------------
# Archives + Checksums
# ---------------------------
archives:
- id: alert_system_linux
builds:
- linux-build
name_template: "alert_system_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: false
format: zip
files:
- LICENSE
checksum:
name_template: "checksums.txt"
algorithm: sha256
103 changes: 0 additions & 103 deletions .goreleaser.yml

This file was deleted.

Loading
Loading