-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add static binary build to GHA workflow
- Loading branch information
Showing
7 changed files
with
179 additions
and
40 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,38 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
push: | ||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.x | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Dependencies | ||
run: | | ||
sudo apt update | ||
sudo apt --yes install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config gcc | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 | ||
- name: Verify | ||
run: | | ||
./scripts/verify.sh | ||
- name: Test | ||
run: | | ||
./scripts/test.sh | ||
- name: Static Build | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: "~> v2" | ||
args: build --clean --snapshot |
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,51 @@ | ||
name: CI | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# - name: Login to DockerHub | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# registry: ${{ vars.PUBLIC_REGISTRY }} | ||
# username: ${{ secrets.PUBLIC_REGISTRY_USERNAME }} | ||
# password: ${{ secrets.PUBLIC_REGISTRY_PASSWORD }} | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.x | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Dependencies | ||
run: | | ||
sudo apt update | ||
sudo apt --yes install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config gcc | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 | ||
- name: Verify | ||
run: | | ||
./scripts/verify.sh | ||
- name: Test | ||
run: | | ||
./scripts/test.sh | ||
- name: Static Build | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: "~> v2" | ||
args: release --clean | ||
# - name: Image Push | ||
# run: | | ||
# make image-push | ||
# env: | ||
# TAG: ${{ github.ref_name }} | ||
# REPO: ${{ vars.PUBLIC_REGISTRY }}/${{ vars.PUBLIC_REGISTRY_REPO }} |
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,53 @@ | ||
version: 2 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- id: hangar | ||
main: ./main.go | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
tags: | ||
- containers_image_openpgp | ||
- exclude_graphdriver_btrfs | ||
- exclude_graphdriver_devicemapper | ||
flags: | ||
- -buildmode=pie | ||
ldflags: | ||
- -extldflags -static | ||
- -s -w | ||
- -X github.com/cnrancher/hangar/pkg/utils.Version={{.Version}} | ||
binary: hangar | ||
|
||
release: | ||
prerelease: auto | ||
|
||
archives: | ||
- format: tar.gz | ||
wrap_in_directory: true | ||
files: | ||
- LICENSE | ||
- README.md | ||
# this name template makes the OS and Arch compatible with the results of `uname`. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
cd $(dirname $0)/.. | ||
WORKINGDIR=$(pwd) | ||
|
||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
echo 'Ensure git directory is clean before run this script:' | ||
git status --short | ||
exit 1 | ||
fi | ||
|
||
echo 'Running: go mod verify' | ||
go mod verify | ||
|
||
echo 'Running: go fmt' | ||
go fmt | ||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
echo 'go fmt produced differences' | ||
exit 1 | ||
fi | ||
|
||
echo 'Running: go generate' | ||
go generate | ||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
echo 'go generate produced differences' | ||
exit 1 | ||
fi | ||
|
||
echo 'Running: go mod tidy' | ||
go mod tidy | ||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
echo 'go mod tidy produced differences' | ||
exit 1 | ||
fi |