Skip to content

Commit

Permalink
Use Goreleaser for releases (#547)
Browse files Browse the repository at this point in the history
* add goreleaser build

* Add post build hook, add goreleaser to install-tools

* create separate post-build script so globbing works

On another note, the sed stuff was entirely unneccessary,
Probably an artifact of some older build process.

* add release workflow for github actions

* enable github release

* remove github release publish from circleci

* modify postscript to include plugins

* github workflow name should be release

* pin goreleaser version, check for latest go

* revert build target changes

* bump goreleaser version to v1.5.0
  • Loading branch information
BinaryFissionGames authored Feb 15, 2022
1 parent 3b23e5c commit ed8843f
Show file tree
Hide file tree
Showing 8 changed files with 739 additions and 31 deletions.
21 changes: 0 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ jobs:
export GIT_TAG="$CIRCLE_TAG"
make install-tools
make build-all
sed "s|/releases/latest/download|/releases/download/$VERSION|g" < ./scripts/unix-install.sh > ./artifacts/unix-install.sh
sed "s|/releases/latest/download|/releases/download/$VERSION|g" < ./scripts/windows-install.ps1 > ./artifacts/windows-install.ps1
- persist_to_workspace:
root: ./artifacts
paths:
Expand Down Expand Up @@ -117,17 +115,6 @@ jobs:
steps:
- run: echo 'Validation Jobs Complete'

publish-github-release:
docker:
- image: cibuilds/github:0.10
steps:
- attach_workspace:
at: ./artifacts
- run:
name: "Publish Release on GitHub"
command: |
ghr -t ${GHI_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} ./artifacts/
publish-docker-release:
# building amd64 + arm64 is compute intensive
resource_class: 2xlarge
Expand Down Expand Up @@ -561,14 +548,6 @@ workflows:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+.*/
- publish-github-release:
requires:
- wait-for-validation
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+.*/
- publish-docker-release:
requires:
- wait-for-validation
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: "ubuntu-20.04"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Required for goreleaser changelog to work properly
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
check-latest: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: "v1.5.0"
args: release --rm-dist
env:
# Default github token should have enough permissions to make a release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
builds:
- id: stanza
binary: stanza_{{ .Os }}_{{ .Arch }}
main: ./cmd/stanza
env:
- CGO_ENABLED=0
flags:
-tags=timetzdata
mod_timestamp: '{{ .CommitTimestamp }}'
goos:
- windows
- linux
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
ldflags:
- -X github.com/observiq/stanza/version.GitTag={{ .Tag }}
- -X github.com/observiq/stanza/version.GitCommit={{ .FullCommit }}
no_unique_dist_dir: true
hooks:
post: ./build/post.sh

archives:
- builds:
- stanza
# skip archiving as tar.gz / zip
format: binary

checksum:
name_template: '{{ .ProjectName }}-v{{ .Version }}-SHA256SUMS'
algorithm: sha256

release:
github:
owner: observIQ
name: stanza

changelog:
skip: false
use: github

dist: artifacts
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ install-tools:
cd $(TOOLS_MOD_DIR) && go install github.com/uw-labs/lichen
cd $(TOOLS_MOD_DIR) && go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment
cd $(TOOLS_MOD_DIR) && go install github.com/observiq/amazon-log-agent-benchmark-tool/cmd/logbench
cd $(TOOLS_MOD_DIR) && go install github.com/goreleaser/goreleaser
cd $(TOOLS_MOD_DIR) && go install github.com/securego/gosec/v2/cmd/[email protected]

.PHONY: scan-license
Expand Down Expand Up @@ -134,6 +135,10 @@ build-linux-arm64:
build-windows-amd64:
@GOOS=windows GOARCH=amd64 $(MAKE) build

.PHONY: release-test
release-test: install-tools
goreleaser release --rm-dist --skip-publish --skip-announce --skip-validate

.PHONY: for-all
for-all:
@set -e; for dir in $(ALL_MODULES); do \
Expand Down
20 changes: 20 additions & 0 deletions build/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
# This script is the post-build script for goreleaser.
# Because it is run for each bbinary built, and global post-release hooks are
# not available in the OSS version, we check for file existence to avoid multiple downloads/copies.

if [ ! -f ./artifacts/stanza-plugins.tar.gz ]; then
curl -fL https://github.com/observiq/stanza-plugins/releases/latest/download/stanza-plugins.tar.gz -o ./artifacts/stanza-plugins.tar.gz
fi
if [ ! -f ./artifacts/stanza-plugins.zip ]; then
curl -fL https://github.com/observiq/stanza-plugins/releases/latest/download/stanza-plugins.tar.gz -o ./artifacts/stanza-plugins.tar.gz
fi
if [ ! -f ./artifacts/version.json ]; then
curl -fL https://github.com/observiq/stanza-plugins/releases/latest/download/version.json -o ./artifacts/version.json
fi
if [ ! -f ./artifacts/unix-install.sh ]; then
cp ./scripts/unix-install.sh ./artifacts/unix-install.sh
fi
if [ ! -f ./artifacts/windows-install.ps1 ]; then
cp ./scripts/windows-install.ps1 ./artifacts/windows-install.ps1
fi
Loading

0 comments on commit ed8843f

Please sign in to comment.