Skip to content

github actions

github actions #13

Workflow file for this run

name: xtracfg
on: [push]
jobs:
build:
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
runs-on: ${{ matrix.os.runner }}
defaults:
run:
working-directory: ./xtracfg
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.13"
cache-dependency-path: xtracfg/go.sum
- uses: graalvm/setup-graalvm@v1
with:
java-version: "17"
distribution: "liberica"
native-image-job-reports: true
cache: gradle
cache-dependency-path: |
xtracfg/*.gradle*
xtracfg/**/gradle-wrapper.properties
- 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' }}
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
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
- name: build java
run: |
./gradlew nativeCompile ${{ matrix.os.type == 'linux' && '-PSTATIC=true' || '' }}
- 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/[email protected]
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