-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
2 changed files
with
72 additions
and
86 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 |
---|---|---|
|
@@ -8,63 +8,43 @@ on: | |
jobs: | ||
build: | ||
name: Build | ||
strategy: | ||
matrix: | ||
os: [linux, darwin] | ||
arch: [amd64, arm64] | ||
include: | ||
- os: linux | ||
runson: ubuntu-latest | ||
- os: darwin | ||
runson: macos-latest | ||
exclude: | ||
- os: darwin | ||
arch: arm64 | ||
runs-on: ${{ matrix.runson }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go 1.22 | ||
if: matrix.arch == 'amd64' | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.22 | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Build Binary - ${{ matrix.os }} ${{ matrix.arch }} | ||
if: matrix.arch == 'amd64' | ||
run: | | ||
go get -v -t -d ./... | ||
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o oaspos | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build Binary - ${{ matrix.os }} ${{ matrix.arch }} | ||
if: matrix.arch == 'arm64' | ||
run: | | ||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
docker run --rm -t \ | ||
-v ${{ github.workspace }}:${{ github.workspace }} \ | ||
-w ${{ github.workspace }} \ | ||
-e GOOS=${{ matrix.os }} \ | ||
-e GOARCH=${{ matrix.arch }} \ | ||
arm64v8/golang:1.22.9-bullseye go build -o oaspos | ||
- name: Build and Push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: false | ||
outputs: ./binaries | ||
|
||
- name: Compress Binary | ||
run: zip oaspos-${{ matrix.os }}-${{ matrix.arch }}.zip ./oaspos | ||
- name: Compress Binaries | ||
run: | | ||
cd binaries | ||
for arch in $(ls); do | ||
test -d $arch || continue | ||
(cd $arch && zip -q - oaspos) > oaspos-${{ github.ref_name }}-${arch}.zip | ||
done | ||
ls -la | ||
- name: Upload Artifact | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ github.ref_name }} | ||
path: oaspos-${{ matrix.os }}-${{ matrix.arch }}.zip | ||
path: binaries/oaspos-*.zip | ||
|
||
release: | ||
name: Release | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
|
@@ -75,51 +55,12 @@ jobs: | |
run: (cd artifacts && sha256sum *) > sha256sums.txt | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag_name: ${{ github.ref_name }} | ||
release_name: Release ${{ github.ref_name }} | ||
name: Release ${{ github.ref_name }} | ||
draft: true | ||
|
||
- name: Upload Asset - Linux x86_64 | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: artifacts/oaspos-linux-amd64.zip | ||
asset_name: oaspos-${{ github.ref_name }}-linux-amd64.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload Asset - Linux arm64 | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: artifacts/oaspos-linux-arm64.zip | ||
asset_name: oaspos-${{ github.ref_name }}-linux-arm64.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload Asset - macos | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: artifacts/oaspos-darwin-amd64.zip | ||
asset_name: oaspos-${{ github.ref_name }}-macos.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload Asset - sha256sums.txt | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: sha256sums.txt | ||
asset_name: sha256sums.txt | ||
asset_content_type: text/plain | ||
files: | | ||
artifacts/*.zip | ||
sha256sums.txt |
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,45 @@ | ||
# Build stage | ||
FROM golang:1.22.9-bookworm AS setup | ||
|
||
WORKDIR /build | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
ADD . ./ | ||
RUN go build -a -o oaspos | ||
|
||
# Build for linux/amd64 | ||
FROM golang:1.22.9-bookworm AS builder-linux-amd64 | ||
ENV GOOS=linux | ||
ENV GOARCH=amd64 | ||
ENV CGO_ENABLED=0 | ||
|
||
COPY --from=setup /go /go | ||
COPY --from=setup /build /build | ||
RUN cd /build && go build -a -o oaspos | ||
|
||
# Build for linux/arm64 | ||
FROM golang:1.22.9-bookworm AS builder-linux-arm64 | ||
ENV GOOS=linux | ||
ENV GOARCH=arm64 | ||
ENV CGO_ENABLED=0 | ||
|
||
COPY --from=setup /go /go | ||
COPY --from=setup /build /build | ||
RUN cd /build && go build -a -o oaspos | ||
|
||
# Build for darwin/arm64 | ||
FROM golang:1.22.9-bookworm AS builder-darwin-arm64 | ||
ENV GOOS=darwin | ||
ENV GOARCH=arm64 | ||
ENV CGO_ENABLED=0 | ||
|
||
COPY --from=setup /go /go | ||
COPY --from=setup /build /build | ||
RUN cd /build && go build -a -o oaspos | ||
|
||
# Binary extraction stage | ||
FROM scratch AS binaries | ||
COPY --from=builder-linux-amd64 /build/oaspos /linux-amd64/ | ||
COPY --from=builder-linux-arm64 /build/oaspos /linux-arm64/ | ||
COPY --from=builder-darwin-arm64 /build/oaspos /darwin-arm64/ |