From 28ec14302c8a294a640508ee3172ce4181f954c3 Mon Sep 17 00:00:00 2001 From: Andreas Zahnen Date: Thu, 10 Oct 2024 08:57:49 +0200 Subject: [PATCH] github actions --- .github/workflows/xtracfg.yml | 59 ++++++++++++++++++++++++++++++++++- xtracfg/Dockerfile | 2 +- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.github/workflows/xtracfg.yml b/.github/workflows/xtracfg.yml index 79139fc..70840f1 100644 --- a/.github/workflows/xtracfg.yml +++ b/.github/workflows/xtracfg.yml @@ -9,10 +9,13 @@ jobs: os: - runner: ubuntu-latest type: linux + platform: linux-amd64 #- runner: buildjet-2vcpu-ubuntu-2204-arm # type: linux + # platform: linux-arm64 - runner: macos-latest type: macos + platform: darwin-arm64 runs-on: ${{ matrix.os.runner }} defaults: run: @@ -40,7 +43,7 @@ jobs: JAVA_INCLUDE: ${{ matrix.os.type == 'macos' && 'darwin' || 'linux' }} run: | git config --global --add safe.directory $GITHUB_WORKSPACE - CGO_CFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/${JAVA_INCLUDE}" go build -x -buildmode c-archive -o dist/libxtracfg.a -ldflags="-s -w '-extldflags=-z noexecstack' -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitTag=${CI_COMMIT_TAG} -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitSha=${CI_COMMIT_SHA} -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitBranch=${CI_COMMIT_BRANCH}" + CGO_CFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/${JAVA_INCLUDE}" go build -buildmode c-archive -o dist/libxtracfg.a -ldflags="-s -w '-extldflags=-z noexecstack' -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitTag=${CI_COMMIT_TAG} -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitSha=${CI_COMMIT_SHA} -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitBranch=${CI_COMMIT_BRANCH}" - name: log1 run: | ls -lR ./dist @@ -50,3 +53,57 @@ jobs: - name: log2 run: | ls -lR ./build/native/nativeCompile + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os.platform }} + path: ./build/native/nativeCompile + retention-days: 1 + + docker: + runs-on: ubuntu-latest + needs: build + steps: + - name: load + uses: actions/download-artifact@v4 + - name: log1 + run: | + ls -lR + - uses: bhowell2/github-substring-action@1.0.2 + id: short-sha + with: + value: ${{ github.sha }} + length_from_start: 7 + - name: login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.ghcr_rw_token }} + - name: buildx + uses: docker/setup-buildx-action@v3 + - name: push + if: ${{ github.ref_name == 'main' }} + uses: docker/build-push-action@v6 + with: + context: . + push: true + pull: true + tags: | + ghcr.io/ldproxy/xtracfg:next + ghcr.io/ldproxy/xtracfg:next-${{steps.short-sha.outputs.substring}} + platforms: | + linux/amd64 + linux/arm64 + - name: push-branch + if: ${{ github.ref_name != 'main' }} + uses: docker/build-push-action@v6 + with: + context: . + push: true + pull: true + tags: | + ghcr.io/ldproxy/xtracfg:${{ github.ref_name }} + ghcr.io/ldproxy/xtracfg:${{ github.ref_name }}-${{steps.short-sha.outputs.substring}} + platforms: | + linux/amd64 + linux/arm64 diff --git a/xtracfg/Dockerfile b/xtracfg/Dockerfile index b83affd..1b6d6a2 100644 --- a/xtracfg/Dockerfile +++ b/xtracfg/Dockerfile @@ -1,6 +1,6 @@ FROM cgr.dev/chainguard/glibc-dynamic:latest ARG TARGETOS ARG TARGETARCH -COPY --chmod=0777 ./$TARGETOS/$TARGETARCH/xtracfg /xtracfg +COPY --chmod=0777 ./$TARGETOS-$TARGETARCH/xtracfg /xtracfg WORKDIR /src ENTRYPOINT ["/xtracfg"]