Update release.yml #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
name: Build and Release | |
jobs: | |
build_and_release: | |
runs-on: ubuntu-latest | |
env: # Define environment variables here | |
TAG: latest | |
RELEASE_NAME: Latest release | |
RELEASE_BODY: Latest release | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BINARY_PREFIX: chap | |
SOURCE_PATH: . | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '*' # Use the latest stable version of Go | |
- name: Install dependencies | |
run: go mod download | |
- name: Download releaseMaker | |
run: wget https://github.com/8ff/releaseMaker/releases/download/latest/releaseMaker.linux.amd64 -O /tmp/releaseMaker && chmod +x /tmp/releaseMaker | |
- name: Build Darwin ARM64 binary | |
working-directory: ${{ env.SOURCE_PATH }} | |
env: | |
OS: darwin | |
ARCH: arm64 | |
run: GOOS=$OS GOARCH=$ARCH go build -ldflags "-X 'main.Version=$(date +'%Y-%m-%d_%H:%M:%S')'" -o "/tmp/build/${{ env.BINARY_PREFIX }}.$OS.$ARCH" | |
- name: Build Darwin AMD64 binary | |
working-directory: ${{ env.SOURCE_PATH }} | |
env: | |
OS: darwin | |
ARCH: amd64 | |
run: GOOS=$OS GOARCH=$ARCH go build -ldflags "-X 'main.Version=$(date +'%Y-%m-%d_%H:%M:%S')'" -o "/tmp/build/${{ env.BINARY_PREFIX }}.$OS.$ARCH" | |
- name: Build Linux ARM64 binary | |
working-directory: ${{ env.SOURCE_PATH }} | |
env: | |
OS: linux | |
ARCH: arm64 | |
run: GOOS=$OS GOARCH=$ARCH go build -ldflags "-X 'main.Version=$(date +'%Y-%m-%d_%H:%M:%S')'" -o "/tmp/build/${{ env.BINARY_PREFIX }}.$OS.$ARCH" | |
- name: Build Linux AMD64 binary | |
working-directory: ${{ env.SOURCE_PATH }} | |
env: | |
OS: linux | |
ARCH: amd64 | |
run: GOOS=$OS GOARCH=$ARCH go build -ldflags "-X 'main.Version=$(date +'%Y-%m-%d_%H:%M:%S')'" -o "/tmp/build/${{ env.BINARY_PREFIX }}.$OS.$ARCH" | |
- name: Build Windows AMD64 binary | |
working-directory: ${{ env.SOURCE_PATH }} | |
env: | |
OS: windows | |
ARCH: amd64 | |
run: GOOS=$OS GOARCH=$ARCH go build -ldflags "-X 'main.Version=$(date +'%Y-%m-%d_%H:%M:%S')'" -o "/tmp/build/${{ env.BINARY_PREFIX }}.$OS.$ARCH.exe" | |
- name: Build Windows ARM64 binary | |
working-directory: ${{ env.SOURCE_PATH }} | |
env: | |
OS: windows | |
ARCH: arm64 | |
run: GOOS=$OS GOARCH=$ARCH go build -ldflags "-X 'main.Version=$(date +'%Y-%m-%d_%H:%M:%S')'" -o "/tmp/build/${{ env.BINARY_PREFIX }}.$OS.$ARCH.exe" | |
- name: Replace Existing Release | |
run: /tmp/releaseMaker replace ${{ github.repository }} ${{ env.TAG }} "${{ env.RELEASE_NAME }}" "${{ env.RELEASE_BODY }}" | |
- name: Upload the artifacts | |
run: | | |
cd /tmp/build | |
for file in *; do | |
/tmp/releaseMaker upload ${{ github.repository }} ${{ env.TAG }} $file $file | |
done |