Files

168 lines
5.4 KiB
YAML

name: Go
env:
WORKING_DIRECTORY: bindings/c
MACOSX_DEPLOYMENT_TARGET: '10.13'
on:
workflow_dispatch:
pull_request:
paths:
- 'bindings/c/**'
- 'core/**'
- 'test-data/**'
- '.github/workflows/go.yaml'
push:
tags:
- 'go-v*'
permissions: write-all
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: 'x86_64-apple-darwin'
- host: macos-latest
target: 'aarch64-apple-darwin'
- host: ubuntu-latest
target: 'x86_64-unknown-linux-gnu'
- host: ubuntu-latest
target: 'aarch64-unknown-linux-gnu'
- host: ubuntu-latest
target: 'x86_64-pc-windows-gnu'
name: ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: ${{ matrix.settings.target }}
- uses: ./.github/actions/setup-rust
with:
shared-key: go-${{ matrix.settings.target }}
zig: ${{ matrix.settings.host == 'ubuntu-latest' }}
sccache-bucket: ${{ secrets.SCCACHE_S3_BUCKET }}
sccache-region: ${{ secrets.SCCACHE_AWS_REGION }}
sccache-role-arn: ${{ secrets.SCCACHE_AWS_ROLE_ARN }}
- name: Build (zig, linux)
if: ${{ matrix.settings.host == 'ubuntu-latest' && contains(matrix.settings.target, 'linux') }}
working-directory: bindings/c
run: cargo zigbuild --release --all-features --target ${{ matrix.settings.target }}.${{ env.GLIBC_VERSION }} --locked
- name: Build (zig, windows)
if: ${{ contains(matrix.settings.target, 'windows') }}
working-directory: bindings/c
run: cargo zigbuild --release --all-features --target ${{ matrix.settings.target }} --locked
- name: Build (native)
if: ${{ matrix.settings.host != 'ubuntu-latest' }}
uses: marcopolo/cargo@master
with:
working-directory: bindings/c
args: --release --all-features --target=${{ matrix.settings.target }} --locked
command: build
- name: List folder
run: ls -lh ../../target/${{ matrix.settings.target }}/release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.target }}
path: target/${{ matrix.settings.target }}/release/libzen_ffi.a
if-no-files-found: error
copy-common:
name: Upload common file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: common
path: bindings/c/zen_engine.h
if-no-files-found: error
release:
name: Release
runs-on: ubuntu-latest
environment: release
if: "github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'"
needs:
- build
- copy-common
steps:
- name: Checkout zen-go
uses: actions/checkout@v3
with:
repository: gorules/zen-go
persist-credentials: false
token: ${{ secrets.PAT }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
run: |
mv artifacts/aarch64-apple-darwin/libzen_ffi.a deps/darwin_arm64/
mv artifacts/x86_64-apple-darwin/libzen_ffi.a deps/darwin_amd64/
mv artifacts/aarch64-unknown-linux-gnu/libzen_ffi.a deps/linux_arm64/
mv artifacts/x86_64-unknown-linux-gnu/libzen_ffi.a deps/linux_amd64/
mv artifacts/x86_64-pc-windows-gnu/libzen_ffi.a deps/windows_amd64/libzen_ffi.a
rm -f deps/windows_amd64/libzen_ffi.lib
mv artifacts/common/zen_engine.h zen_engine.h
rm -rf artifacts
- name: Set branch name
run: |
echo "BRANCH_NAME=chore/${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_ENV
- run: git config -l
- name: Commit
run: |
BRANCH_NAME="${{ env.BRANCH_NAME }}"
git checkout -b $BRANCH_NAME
# Setup the committers identity.
git config user.email "bot@gorules.io"
git config user.name "Bot GoRules"
git config http.postBuffer 524288000
git config http.lowSpeedTime 600
# Commit the changes and push the feature branch to origin
git add .
git commit -m "chore: update deps"
- name: Push changes
uses: ad-m/github-push-action@master
with:
repository: gorules/zen-go
github_token: ${{ secrets.PAT }}
branch: ${{ env.BRANCH_NAME }}
- name: Create PR
run: |
BRANCH_NAME="${{ env.BRANCH_NAME }}"
# Store the PAT in a file that can be accessed by the
# GitHub CLI.
echo "${{ secrets.PAT }}" > token.txt
# Authorize GitHub CLI for the current repository and
# create a pull-requests containing the updates.
echo "Authorizing for PR"
gh auth login --with-token < token.txt
gh pr create \
--body "" \
--title "chore: update deps" \
--head "$BRANCH_NAME" \
--base "master"