From 753c99ca0a90dbd20e4e1dd22ce4c016497bd941 Mon Sep 17 00:00:00 2001 From: Mischa Taylor Date: Thu, 20 Jun 2024 19:47:22 -0400 Subject: [PATCH] Build for release --- .github/workflows/release.yml | 155 ++++++++++++++++++++++++++++++++-- 1 file changed, 148 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce4e917..d2ee5cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,16 +7,156 @@ on: workflow_dispatch: jobs: - release: + build: + name: Test + Build + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + arch: [amd64, arm64] + exclude: + - os: windows-latest + arch: arm64 + runs-on: ${{ matrix.os }} + steps: + - name: Set up Go 1.16 + uses: actions/setup-go@v5 + with: + go-version: 1.16 + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + - name: Test on Windows + if: runner.os == 'windows' + run: go test ./... + - name: Test on POSIX + if: runner.os != 'windows' + run: make test + - name: Build on Windows + if: runner.os == 'windows' + run: ${{ matrix.arch == 'amd64' && 'make windows' || 'make windowsARM' }} + env: + GOOS: windows + GOARCH: ${{ matrix.arch }} + shell: bash + - name: Build on OSX + if: runner.os == 'macos' + run: ${{ matrix.arch == 'amd64' && 'make darwin' || 'make darwinARM' }} + env: + GOARCH: ${{ matrix.arch }} + - name: Build on Linux + if: runner.os == 'linux' + run: ${{ matrix.arch == 'amd64' && 'make linux' || 'make linuxARM' }} + env: + GOARCH: ${{ matrix.arch }} + - name: Generate SHA256 checksum on Linux and macOS + if: runner.os != 'Windows' + run: | + shasum -a 256 build/*/*/* > checksums.txt + - name: Generate SHA256 checksum on Windows + if: runner.os == 'Windows' + run: | + certutil -hashfile build/windows/amd64/go2chef.exe SHA256 > checksums.txt + - name: Archive build artifacts on Windows + if: runner.os == 'windows' + uses: actions/upload-artifact@v4 + with: + name: go2chef-windows-${{ matrix.arch }} + path: ${{ runner.os == 'windows' && matrix.arch == 'amd64' && 'build/windows/amd64/go2chef.exe' || 'build/windows/arm64/go2chef.exe' }} + - name: Archive build artifacts on MacOS + if: runner.os == 'macos' + uses: actions/upload-artifact@v4 + with: + name: go2chef-macos-${{ matrix.arch }} + path: ${{ runner.os == 'macos' && matrix.arch == 'amd64' && 'build/darwin/amd64/go2chef' || 'build/darwin/arm64/go2chef' }} + - name: Archive build artifacts on Linux + if: runner.os == 'linux' + uses: actions/upload-artifact@v4 + with: + name: go2chef-linux-${{ matrix.arch }} + path: ${{ runner.os == 'linux' && matrix.arch == 'amd64' && 'build/linux/amd64/go2chef' || 'build/linux/arm64/go2chef' }} +taylor@sheila workflows % clear +taylor@sheila workflows % ls +go.yml release.yml +taylor@sheila workflows % cat go.yml +name: Go2Chef +on: + pull_request: + push: + workflow_dispatch: +jobs: + build: + name: Test + Build + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + arch: [amd64, arm64] + exclude: + - os: windows-latest + arch: arm64 + runs-on: ${{ matrix.os }} + steps: + - name: Set up Go 1.16 + uses: actions/setup-go@v5 + with: + go-version: 1.16 + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + - name: Test on Windows + if: runner.os == 'windows' + run: go test ./... + - name: Test on POSIX + if: runner.os != 'windows' + run: make test + - name: Build on Windows + if: runner.os == 'windows' + run: ${{ matrix.arch == 'amd64' && 'make windows' || 'make windowsARM' }} + env: + GOOS: windows + GOARCH: ${{ matrix.arch }} + shell: bash + - name: Build on OSX + if: runner.os == 'macos' + run: ${{ matrix.arch == 'amd64' && 'make darwin' || 'make darwinARM' }} + env: + GOARCH: ${{ matrix.arch }} + - name: Build on Linux + if: runner.os == 'linux' + run: ${{ matrix.arch == 'amd64' && 'make linux' || 'make linuxARM' }} + env: + GOARCH: ${{ matrix.arch }} + - name: Generate SHA256 checksum on Linux and macOS + if: runner.os != 'Windows' + run: | + shasum -a 256 build/*/*/* > checksums.txt + - name: Generate SHA256 checksum on Windows + if: runner.os == 'Windows' + run: | + certutil -hashfile build/windows/amd64/go2chef.exe SHA256 > checksums.txt + - name: Archive build artifacts on Windows + if: runner.os == 'windows' + uses: actions/upload-artifact@v4 + with: + name: go2chef-windows-${{ matrix.arch }} + path: ${{ runner.os == 'windows' && matrix.arch == 'amd64' && 'build/windows/amd64/go2chef.exe' || 'build/windows/arm64/go2chef.exe' }} + - name: Archive build artifacts on MacOS + if: runner.os == 'macos' + uses: actions/upload-artifact@v4 + with: + name: go2chef-macos-${{ matrix.arch }} + path: ${{ runner.os == 'macos' && matrix.arch == 'amd64' && 'build/darwin/amd64/go2chef' || 'build/darwin/arm64/go2chef' }} + - name: Archive build artifacts on Linux + if: runner.os == 'linux' + uses: actions/upload-artifact@v4 + with: + name: go2chef-linux-${{ matrix.arch }} + path: ${{ runner.os == 'linux' && matrix.arch == 'amd64' && 'build/linux/amd64/go2chef' || 'build/linux/arm64/go2chef' }} + publish: + needs: build runs-on: ubuntu-latest steps: - - name: Check out code - uses: actions/checkout@v4 - name: Download artifacts uses: actions/download-artifact@v4 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: 9604597430 - name: Display structure of downloaded files run: ls -R - name: Upload binaries to release @@ -26,4 +166,5 @@ jobs: file_glob: true file: go2chef-* tag: ${{ github.ref }} - + overwrite: true + draft: true