Skip to content

Build and Publish Launch Releases #50

Build and Publish Launch Releases

Build and Publish Launch Releases #50

name: Build and Publish Launch Releases
on:
release:
types: [published]
jobs:
check_release:
if: "! contains(github.event.release.tag_name, '-dev')" # skip if the tag ends with -dev
runs-on: ubuntu-latest
steps:
- name: Echo tag
run: |
echo "tag name: ${{ github.event.release.tag_name }}"
echo "release name: ${{ github.event.release.name }}"
build:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- { runner: macos-latest, goos: darwin, osname: macOS, arch: amd64, tags: netcgo }
- { runner: macos-latest, goos: darwin, osname: macOS, arch: arm64, tags: netcgo }
- { runner: ubuntu-latest, goos: linux, osname: linux, arch: amd64, env: CGO_ENABLED=0 }
- { runner: ubuntu-latest, goos: linux, osname: linux, arch: arm64, env: CGO_ENABLED=0 }
- { runner: ubuntu-latest, goos: windows, osname: windows, arch: amd64, env: CGO_ENABLED=0, extension: ".exe" }
# - { runner: ubuntu-latest, goos: windows, osname: windows, arch: arm64, env: CGO_ENABLED=0, extension: ".exe" }
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.5'
- name: Build Go app
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.arch }}
run: |
${{ matrix.env }} go build -ldflags="-X main.version={{ github.event.release.tag_name }}" -tags="${{ matrix.tags }}" -o dkn-compute-launcher${{ matrix.extension }} .
- name: Prepare Launch Release Files
env:
FOLDER_NAME: dkn-compute-node
ZIP_NAME: dkn-compute-launcher-${{ matrix.osname }}-${{ matrix.arch }}
run: |
mkdir $FOLDER_NAME
# copy launcher binary
cp ./dkn-compute-launcher${{ matrix.extension }} $FOLDER_NAME/dkn-compute-launcher${{ matrix.extension }}
# download .env.example and save it as .env
curl -o $FOLDER_NAME/.env https://raw.githubusercontent.com/firstbatchxyz/dkn-compute-node/master/.env.example
zip -r $ZIP_NAME.zip $FOLDER_NAME
- name: Upload Launch Artifacts
uses: actions/upload-artifact@v4
with:
name: dkn-compute-launcher-${{ matrix.osname }}-${{ matrix.arch }}
path: dkn-compute-launcher-${{ matrix.osname }}-${{ matrix.arch }}.zip
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all tags and history
- name: Download Launch Artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: ./artifacts
- name: Create release with artifacts
uses: ncipollo/release-action@v1
with:
name: ${{ github.event.release.name }}
tag: ${{ github.event.release.tag_name }}
artifacts: "artifacts/*"
artifactContentType: application/zip
allowUpdates: true
# draft: true