Build and Release #330
Workflow file for this run
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
name: Build and Release | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
build-and-upload: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
- os: [self-hosted, linux, arm64] | |
- os: macos-latest | |
- os: [self-hosted, macos, arm64] | |
- os: windows-latest | |
steps: | |
- shell: bash | |
run: | | |
if [[ ${{ runner.arch }} == "ARM64" ]]; then | |
echo "OUTNAME=${{ runner.os }}_${{ runner.arch }}" >> $GITHUB_ENV | |
else | |
echo "OUTNAME=${{ runner.os }}" >> $GITHUB_ENV | |
fi | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
check-latest: true | |
go-version-file: "go.mod" | |
cache: ${{ runner.arch != 'arm64' }} | |
- if: matrix.os == 'windows-latest' | |
name: Install dependencies in windows | |
uses: crazy-max/ghaction-chocolatey@v2 | |
with: | |
args: install make wget zip | |
- name: setup env | |
run: | | |
echo "::set-env name=GOPATH::$(go env GOPATH)" | |
echo "::add-path::$(go env GOPATH)/bin" | |
shell: bash | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' | |
- name: Read version.txt | |
id: version | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ./version.txt | |
- name: Add OpenCL support for Linux | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: sudo apt-get update -q && sudo apt-get install -qy ocl-icd-opencl-dev libpocl2 | |
- name: Override SDKROOT for macOS | |
if: ${{ contains(matrix.os, 'macos') && runner.arch == 'arm64' }} | |
run: echo "SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk" >> $GITHUB_ENV | |
# `make build` reads version from version.txt but in Windows it doesn't work therefore passing version explicitly | |
- name: Build go-spacemesh | |
shell: bash | |
run: | | |
make install | |
make build VERSION=${{ steps.version.outputs.content }} BIN_DIR_WIN=./build | |
- name: Create release archive | |
shell: bash | |
env: | |
OUTNAME: ${{ env.OUTNAME }} | |
run: | | |
mkdir $OUTNAME | |
mv ./build/* $OUTNAME | |
rm -f $OUTNAME/post.h | |
zip -r $OUTNAME.zip $OUTNAME | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
export_default_credentials: true | |
- name: Upload zip | |
uses: google-github-actions/upload-cloud-storage@v0 | |
with: | |
path: ${{ env.OUTNAME }}.zip | |
destination: ${{ secrets.GCP_BUCKET }}/${{ steps.version.outputs.content }}/ | |
release: | |
runs-on: ubuntu-latest | |
needs: build-and-upload | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
- name: Read version.txt | |
id: version | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ./version.txt | |
- name: Create Release | |
uses: actions/create-release@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ steps.version.outputs.content }} | |
body: | | |
## Zip Files | |
- Windows: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ steps.version.outputs.content }}/Windows.zip | |
- macOS: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ steps.version.outputs.content }}/macOS.zip | |
- macOS arm64: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ steps.version.outputs.content }}/macOS_ARM64.zip | |
- Linux: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ steps.version.outputs.content }}/Linux.zip | |
- Linux arm64: https://storage.googleapis.com/${{ secrets.GCP_BUCKET }}/${{ steps.version.outputs.content }}/Linux_ARM64.zip | |
draft: false | |
prerelease: true |