From a466687d88d8120e7623638e9f5b462c8960ac6e Mon Sep 17 00:00:00 2001 From: OhMyDaHal Date: Thu, 11 Jul 2024 09:59:20 +0200 Subject: [PATCH] Create go.yml --- .github/workflows/go.yml | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..2000d77 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,72 @@ +name: Go Multiarch Build and Release + +on: + push: + branches: [ "main" ] + tags: + - "v*.*.*" + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + goos: [linux, darwin, windows] + goarch: [amd64, arm64] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22.4" + + - name: Build + run: | + mkdir -p dist + EXT="" + if [ "${{ matrix.goos }}" == "windows" ]; then EXT=".exe"; fi + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/crdtokcl-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} . + + - name: Upload binary + uses: actions/upload-artifact@v2 + with: + name: crdtokcl-${{ matrix.goos }}-${{ matrix.goarch }} + path: dist/crdtokcl-${{ matrix.goos }}-${{ matrix.goarch }} + + release: + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v4 + + - name: Download binaries + uses: actions/download-artifact@v2 + with: + path: dist + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: Release ${{ github.ref_name }} + draft: false + prerelease: false + + - name: Upload Release Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/ + asset_name: crdtokcl-${{ matrix.goos }}-${{ matrix.goarch }} + asset_content_type: application/octet-stream