Skip to content

ci: trying to push binaries reliably (9) #20

ci: trying to push binaries reliably (9)

ci: trying to push binaries reliably (9) #20

name: Build and Commit Go Binaries
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.22' # Replace with your Go version
# - name: Set up GCC
# uses: egor-tensin/setup-gcc@v1
# with:
# version: latest
# platform: ${{ matrix.goarch }}
- name: Build binary
run: |
cd shuffle_email_rules/lib/
go mod tidy
mkdir -p build/${{ matrix.goos }}_${{ matrix.goarch }}
go build -v -o build/libshuffleemail_${{ matrix.goos }}_${{ matrix.goarch }} -buildmode=c-shared
env:
CGO_ENABLED: 1
# GOOS: ${{ matrix.goos }}
# GOARCH: ${{ matrix.goarch }}
- name: Commit binaries
run: |
cd shuffle_email_rules/lib/
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
mkdir -p binaries/
mv build/libshuffleemail_${{ matrix.goos }}_${{ matrix.goarch }} binaries/
git add binaries/
git commit -m "Add compiled binaries for ${{ matrix.goos }} - ${{ matrix.goarch }}"
git checkout -b "binaries-${{ matrix.goos }}-${{ matrix.goarch }}_$(date +'%Y%m%d%H%M%S')"
- name: Make a PR
run: |
cd shuffle_email_rules/lib/
git push origin "binaries-${{ matrix.goos }}-${{ matrix.goarch }}_$(date +'%Y%m%d%H%M%S')"
gh pr create --title "Add compiled binaries for ${{ matrix.goos }} - ${{ matrix.goarch }}" --body "Add compiled binaries for ${{ matrix.goos }} - ${{ matrix.goarch }}" --base main --head "binaries-${{ matrix.goos }}-${{ matrix.goarch }}_$(date +'%Y%m%d%H%M%S')"