mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-09-13 13:00:10 +00:00
78 lines
2.9 KiB
YAML
78 lines
2.9 KiB
YAML
name: Build and Upload assets
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
|
name: Building For ${{ matrix.os }}
|
|
steps:
|
|
- name: Fix windows CRLF
|
|
run: git config --global core.autocrlf false
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v2
|
|
|
|
# We need to increase the page size because the tests run out of memory on github CI windows.
|
|
# Use the powershell script from this github action: https://github.com/al-cheb/configure-pagefile-action/blob/master/scripts/SetPageFileSize.ps1
|
|
# MIT License (MIT) Copyright (c) 2020 Maxim Lobanov and contributors
|
|
- name: Increase page size on windows
|
|
if: runner.os == 'Windows'
|
|
shell: powershell
|
|
run: powershell -command .\.github\workflows\SetPageFileSize.ps1
|
|
|
|
|
|
- name: Set up Go 1.x
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: 1.16
|
|
|
|
- name: Build on linux
|
|
if: runner.os == 'Linux'
|
|
# `-extldflags=-static` - means static link everything, `-tags netgo,osusergo` means use pure go replacements for "os/user" and "net"
|
|
# `-s -w` strips the binary to produce smaller size binaries
|
|
run: |
|
|
go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ ./...
|
|
archive="bin/kaspad-${{ github.event.release.tag_name }}-linux.zip"
|
|
asset_name="kaspad-${{ github.event.release.tag_name }}-linux.zip"
|
|
zip -r "${archive}" ./bin/*
|
|
echo "archive=${archive}" >> $GITHUB_ENV
|
|
echo "asset_name=${asset_name}" >> $GITHUB_ENV
|
|
|
|
- name: Build on Windows
|
|
if: runner.os == 'Windows'
|
|
shell: bash
|
|
run: |
|
|
go build -v -ldflags="-s -w" -o bin/ ./...
|
|
archive="bin/kaspad-${{ github.event.release.tag_name }}-win64.zip"
|
|
asset_name="kaspad-${{ github.event.release.tag_name }}-win64.zip"
|
|
powershell "Compress-Archive bin/* \"${archive}\""
|
|
echo "archive=${archive}" >> $GITHUB_ENV
|
|
echo "asset_name=${asset_name}" >> $GITHUB_ENV
|
|
|
|
- name: Build on MacOS
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
go build -v -ldflags="-s -w" -o ./bin/ ./...
|
|
archive="bin/kaspad-${{ github.event.release.tag_name }}-osx.zip"
|
|
asset_name="kaspad-${{ github.event.release.tag_name }}-osx.zip"
|
|
zip -r "${archive}" ./bin/*
|
|
echo "archive=${archive}" >> $GITHUB_ENV
|
|
echo "asset_name=${asset_name}" >> $GITHUB_ENV
|
|
|
|
|
|
- name: Upload Release Asset
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_path: "./${{ env.archive }}"
|
|
asset_name: "${{ env.asset_name }}"
|
|
asset_content_type: application/zip
|