This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f8de63
commit 9fdafa3
Showing
4 changed files
with
160 additions
and
3 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,68 @@ | ||
name: Test & Release | ||
|
||
on: | ||
- push | ||
- workflow_dispatch | ||
|
||
env: | ||
GO_VERSION: "1.22.x" | ||
|
||
jobs: | ||
test-suite: | ||
timeout-minutes: 30 | ||
name: Full Test Suite | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
# Setup | ||
- uses: actions/checkout@v3 | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "${{ env.GO_VERSION }}" | ||
# Tests | ||
- name: Run Go Tests | ||
run: make test | ||
# Builds | ||
- name: Test Platform Builds | ||
run: make build-cross | ||
|
||
|
||
release-github: | ||
name: Build & Release Binaries | ||
# Only run on tags | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
# Setup | ||
- uses: actions/checkout@v3 | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "${{ env.GO_VERSION }}" | ||
- name: Setup CI Tools | ||
run: make ci-setup | ||
# Go Build | ||
- name: Build k3d Binary | ||
run: make gen-checksum build-cross | ||
# Create Git Release | ||
- name: Extract Tag from Ref | ||
if: startsWith(github.ref, 'refs/tags/') | ||
id: tag | ||
run: echo VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT | ||
shell: bash | ||
- uses: apexskier/github-semver-parse@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
id: semver | ||
with: | ||
version: ${{ steps.tag.outputs.VERSION }} | ||
- name: Create Release | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
artifactErrorsFailBuild: true | ||
artifacts: _dist/* | ||
discussionCategory: releases | ||
generateReleaseNotes: true | ||
prerelease: ${{ steps.semver.outputs.prerelease != '' }} | ||
replacesArtifacts: true | ||
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
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
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,60 @@ | ||
#!/bin/sh | ||
|
||
# initArch discovers the architecture for this system. | ||
initArch() { | ||
if [ -z $ARCH ]; then | ||
ARCH=$(uname -m) | ||
case $ARCH in | ||
armv5*) ARCH="armv5";; | ||
armv6*) ARCH="armv6";; | ||
armv7*) ARCH="arm";; | ||
aarch64) ARCH="arm64";; | ||
x86) ARCH="386";; | ||
x86_64) ARCH="amd64";; | ||
i686) ARCH="386";; | ||
i386) ARCH="386";; | ||
esac | ||
fi | ||
} | ||
|
||
# initOS discovers the operating system for this system. | ||
initOS() { | ||
if [ -z $OS ]; then | ||
OS=$(uname|tr '[:upper:]' '[:lower:]') | ||
|
||
case "$OS" in | ||
# Minimalist GNU for Windows | ||
mingw*) OS='windows';; | ||
esac | ||
fi | ||
} | ||
|
||
|
||
install_golangci_lint() { | ||
echo "Installing golangci-lint..." | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0 | ||
} | ||
|
||
install_gox() { | ||
echo "Installing gox for $OS/$ARCH..." | ||
GOX_REPO=iwilltry42/gox | ||
GOX_VERSION=0.1.0 | ||
curl -sSfL https://github.com/${GOX_REPO}/releases/download/v${GOX_VERSION}/gox_${GOX_VERSION}_${OS}_${ARCH}.tar.gz | tar -xz -C /tmp | ||
chmod +x /tmp/gox | ||
mv /tmp/gox /usr/local/bin/gox | ||
} | ||
|
||
# | ||
# MAIN | ||
# | ||
|
||
initOS | ||
initArch | ||
|
||
for pkg in "$@"; do | ||
case "$pkg" in | ||
golangci-lint) install_golangci_lint;; | ||
gox) install_gox;; | ||
*) printf "ERROR: Unknown Package '%s'" $pkg;; | ||
esac | ||
done |