Skip to content

refactor build

refactor build #37

Workflow file for this run

name: xtracfg
on: [push]
jobs:
libraries:
runs-on: ${{ matrix.os.runner }}
strategy:
matrix:
os:
#- runner: ubuntu-latest
# type: linux
# platform: linux-amd64
#- runner: buildjet-2vcpu-ubuntu-2204-arm
# type: linux
# platform: linux-arm64
- runner: macos-15
type: macos
platform: darwin-arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23.2"
cache-dependency-path: xtracfg/go.sum
- uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
distribution: "graalvm"
native-image-job-reports: true
cache: gradle
cache-dependency-path: |
xtracfg/*.gradle*
xtracfg/**/gradle-wrapper.properties
- name: java
working-directory: ./libxtracfg/java
run: |
./gradlew nativeCompile -PLIB=true
- name: log
run: |
ls -l ./libxtracfg/c/build
- name: c
working-directory: ./libxtracfg/c
run: |
./build.sh
- name: log2
run: |
ls -l ./libxtracfg/c/build
- uses: actions/upload-artifact@v4
with:
name: libxtracfg-c-${{ matrix.os.platform }}
path: ./libxtracfg/c/build/libxtracfg.a
retention-days: 1
- uses: actions/upload-artifact@v4
with:
name: libxtracfg-c-hash-${{ matrix.os.platform }}
path: ./libxtracfg/go/xtracfg/libxtracfg.sha1sum
retention-days: 1
binary:
runs-on: ${{ matrix.os.runner }}
needs: libraries
strategy:
matrix:
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
defaults:
run:
working-directory: ./xtracfg
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23.2"
cache-dependency-path: xtracfg/go.sum
- uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
distribution: "graalvm"
native-image-job-reports: true
cache: gradle
cache-dependency-path: |
xtracfg/*.gradle*
xtracfg/**/gradle-wrapper.properties
- uses: actions/download-artifact@v4
with:
name: libxtracfg-c-${{ matrix.os.platform }}
- uses: actions/download-artifact@v4
with:
name: libxtracfg-c-hash-${{ matrix.os.platform }}
- name: log2
run: |
ls -l ../
ls -l ./
ls -l ./build
- name: build go
env:
CI_COMMIT_BRANCH: ${{ github.ref_name }}
CI_COMMIT_SHA: ${{ github.sha }}
CI_COMMIT_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
# JAVA_INCLUDE: ${{ matrix.os.type == 'macos' && 'darwin' || 'linux' }}
# -s -w '-extldflags=-z noexecstack'
CGO_LDFLAGS: "${{ matrix.os.type == 'macos' && '-framework CoreServices -framework Foundation' || '' }} -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}"
run: |
#git config --global --add safe.directory $GITHUB_WORKSPACE
go build -o build/xtracfg
- name: log1
run: |
ls -lR ./build
- uses: docker://backplane/upx:latest
with:
args: upx --best xtracfg/build/xtracfg
- name: log2
run: |
ls -lR ./build
- uses: actions/upload-artifact@v4
with:
name: xtracfg-${{ matrix.os.platform }}
path: ./xtracfg/build/xtracfg
retention-days: 1
- uses: actions/upload-artifact@v4
if: ${{ matrix.os.platform == 'linux-amd64' }}
with:
name: common
path: ./xtracfg/Dockerfile
retention-days: 1
docker:
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
needs: binary
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: .
file: ./common/Dockerfile
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