Build fixes
This commit is contained in:
24
.github/workflows/build.yml
vendored
24
.github/workflows/build.yml
vendored
@@ -9,7 +9,15 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set version
|
||||||
|
id: version
|
||||||
|
run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/})"
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
@@ -35,7 +43,7 @@ jobs:
|
|||||||
-X 'version.BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)'
|
-X 'version.BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)'
|
||||||
-X 'version.GoVersion=$(go version)'
|
-X 'version.GoVersion=$(go version)'
|
||||||
-X 'version.GitCommit=$(git rev-parse HEAD)'
|
-X 'version.GitCommit=$(git rev-parse HEAD)'
|
||||||
-X 'version.Version=${{ github.ref }}'
|
-X 'version.Version=${{ steps.version.outputs.version }}'
|
||||||
buildmode: default
|
buildmode: default
|
||||||
trimpath: true
|
trimpath: true
|
||||||
|
|
||||||
@@ -43,7 +51,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p compressed_artifacts
|
mkdir -p compressed_artifacts
|
||||||
for platform in windows-amd64.exe linux-amd64 linux-arm64 darwin-arm64; do
|
for platform in windows-amd64.exe linux-amd64 linux-arm64 darwin-arm64; do
|
||||||
zip -r "compressed_artifacts/zurg-$platform-${{ github.ref }}.zip" "artifacts/zurg-$platform"
|
zip -r "compressed_artifacts/zurg-${{ steps.version.outputs.version }}-$platform.zip" "artifacts/zurg-$platform"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Upload artifacts to workflow
|
- name: Upload artifacts to workflow
|
||||||
@@ -57,6 +65,10 @@ jobs:
|
|||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set version
|
||||||
|
id: version
|
||||||
|
run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/})"
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -68,8 +80,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref }}
|
tag_name: ${{ steps.version.outputs.version }}
|
||||||
release_name: Release ${{ github.ref }}
|
release_name: Release ${{ steps.version.outputs.version }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
@@ -78,10 +90,10 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
for platform in windows/amd64 linux/amd64 linux/arm64 darwin/arm64; do
|
for platform in windows/amd64 linux/amd64 linux/arm64 darwin/arm64; do
|
||||||
asset_path="./compressed_artifacts/zurg-$platform-${{ github.ref }}.zip"
|
asset_path="./compressed_artifacts/zurg-$platform-${{ steps.version.outputs.version }}.zip"
|
||||||
if [[ -f "$asset_path" ]]; then
|
if [[ -f "$asset_path" ]]; then
|
||||||
echo "Uploading $asset_path"
|
echo "Uploading $asset_path"
|
||||||
gh release upload ${{ github.ref }} "$asset_path" --c ${{ secrets.GITHUB_TOKEN }}
|
gh release upload ${{ steps.version.outputs.version }} "$asset_path" --c ${{ secrets.GITHUB_TOKEN }}
|
||||||
else
|
else
|
||||||
echo "File not found: $asset_path"
|
echo "File not found: $asset_path"
|
||||||
fi
|
fi
|
||||||
|
|||||||
27
.github/workflows/build_docker.yml
vendored
27
.github/workflows/build_docker.yml
vendored
@@ -1,22 +1,23 @@
|
|||||||
name: Build zurg-testing docker image
|
name: Build Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
tags:
|
tags:
|
||||||
- v0*
|
- 'v*'
|
||||||
paths:
|
|
||||||
- '**.go'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push-image:
|
build-and-push-image:
|
||||||
|
name: Docker Build
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set version
|
||||||
|
id: version
|
||||||
|
run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/})"
|
||||||
|
|
||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -54,16 +55,21 @@ jobs:
|
|||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
build-args: |
|
||||||
|
BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)
|
||||||
|
GoVersion=$(go version)
|
||||||
|
GitCommit=$(git rev-parse HEAD)
|
||||||
|
Version=${{ steps.version.outputs.version }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
if: startsWith(github.ref, 'refs/tags/v0')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
id: publicmeta
|
id: publicmeta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/${{ github.repository }}-testing
|
images: ghcr.io/${{ github.repository }}-testing
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
if: startsWith(github.ref, 'refs/tags/v0')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -73,3 +79,8 @@ jobs:
|
|||||||
labels: ${{ steps.publicmeta.outputs.labels }}
|
labels: ${{ steps.publicmeta.outputs.labels }}
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
build-args: |
|
||||||
|
BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)
|
||||||
|
GoVersion=$(go version)
|
||||||
|
GitCommit=$(git rev-parse HEAD)
|
||||||
|
Version=${{ steps.version.outputs.version }}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
# Accept GOOS and GOARCH as build arguments
|
# Accept GOOS and GOARCH as build arguments
|
||||||
ARG GOOS=linux
|
ARG GOOS=linux
|
||||||
ARG GOARCH=amd64
|
ARG GOARCH=amd64
|
||||||
|
ARG BuiltAt
|
||||||
|
ARG GoVersion
|
||||||
|
ARG GitCommit
|
||||||
|
ARG Version
|
||||||
|
|
||||||
# Build stage
|
# Build stage
|
||||||
FROM golang:1-alpine AS builder
|
FROM golang:1-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN apk add --no-cache bash git go gcc musl-dev curl fuse
|
RUN apk add --no-cache bash git go gcc musl-dev curl fuse
|
||||||
RUN go build -o zurg cmd/zurg/main.go
|
RUN go build -ldflags="-s -w -X 'main.BuiltAt=${BuiltAt}' -X 'main.GoVersion=${GoVersion}' -X 'main.GitCommit=${GitCommit}' -X 'main.Version=${Version}'" -o zurg cmd/zurg/main.go
|
||||||
|
|
||||||
# Obfuscation stage
|
# Obfuscation stage
|
||||||
FROM alpine:3 AS obfuscator
|
FROM alpine:3 AS obfuscator
|
||||||
|
|||||||
Reference in New Issue
Block a user