-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Release Workflow and Build Script for Automated Releases (#190)
Signed-off-by: Max Lambrecht <[email protected]>
- Loading branch information
Max Lambrecht
authored
Jun 5, 2023
1 parent
72f2e5f
commit a7b8f85
Showing
3 changed files
with
110 additions
and
10 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,61 @@ | ||
name: Release Build | ||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' # Trigger this workflow when a new vX.Y.Z tag is pushed | ||
env: | ||
GO_VERSION: 1.20.3 | ||
|
||
jobs: | ||
build: | ||
name: Build Artifacts | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
actions: read | ||
steps: | ||
- name: Setup go | ||
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Check out code | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | ||
|
||
- name: Get dependencies | ||
run: go mod download | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
|
||
- name: Build Artifacts | ||
run: ./.github/workflows/scripts/build_artifacts.sh | ||
|
||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | ||
with: | ||
name: release-artifacts | ||
path: | | ||
galadriel-*-linux-*-glibc.tar.gz | ||
galadriel-*-linux-*-glibc.tar.gz.sha256sum.txt | ||
release: | ||
name: Release | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Download Artifacts | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: release-artifacts | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@26994186c0ac3ef5cae75ac16aa32e8153525f77 # v1 | ||
with: | ||
files: | | ||
galadriel-*-linux-*-glibc.tar.gz | ||
galadriel-*-linux-*-glibc.tar.gz.sha256sum.txt | ||
env: | ||
GITHUB_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
# Builds Galadriel artifacts for Linux for all supported architectures. | ||
# Usage: build_artifacts.sh | ||
|
||
set -e | ||
|
||
supported_architectures=(amd64 arm64) | ||
|
||
export version_tag= | ||
if [[ "$GITHUB_REF" =~ ^refs/tags/v[0-9.]+$ ]]; then | ||
# Strip off the leading "v" from the release tag. Release artifacts are | ||
# named just with the version number (e.g. v0.9.3 tag produces | ||
# galadriel-0.9.3-linux-x64.tar.gz). | ||
version_tag="${GITHUB_REF##refs/tags/v}" | ||
fi | ||
|
||
for architecture in "${supported_architectures[@]}"; do | ||
# Build the server and harvester binaries for the current architecture | ||
if GOARCH=$architecture make build; then | ||
echo "Artifacts successfully built for architecture: ${architecture}" | ||
tarball="galadriel-${version_tag}-linux-${architecture}-glibc.tar.gz" | ||
|
||
# Create a tarball with the binaries, license, and conf files | ||
tar -czvf "$tarball" -C bin/ . -C ../ LICENSE conf/ | ||
|
||
# Generate a SHA-256 checksum for the tarball | ||
sha256sum "$tarball" > "$tarball.sha256sum.txt" | ||
else | ||
echo "Error encountered while building artifact for architecture: ${architecture}" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Build completed successfully for all architectures" |
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