Skip to content

Commit

Permalink
Add GH Workflow to build binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
WalBeh committed Nov 28, 2024
1 parent 2327ca8 commit f2809e9
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/build-and-release-dc_util.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build and Release dc_util

on:
workflow_dispatch:
inputs:
release_version:
description: 'Version number for the release (e.g., v1.0.0)'
required: true
default: 'v1.0.0'

jobs:
build-and-release:
runs-on: ubuntu-latest
strategy:
matrix:
# os: [linux, windows, darwin]
os: [linux]
# goarch: [amd64, arm64]
goarch: [amd64]

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Build dc_util
run: |
mkdir -p build
cd utils/dc_util # Navigate to the directory containing dc_util.go
GOOS=${{ matrix.os }} GOARCH=${{ matrix.goarch }} go build -o ../../build/dc_util-${{ matrix.os }}-${{ matrix.goarch }}
- name: Generate SHA256 Checksum
run: |
cd build
if [[ "${{ matrix.os }}" == "windows" ]]; then
sha256sum dc_util-${{ matrix.os }}-${{ matrix.goarch }}.exe > dc_util-${{ matrix.os }}-${{ matrix.goarch }}.exe.sha256
else
sha256sum dc_util-${{ matrix.os }}-${{ matrix.goarch }} > dc_util-${{ matrix.os }}-${{ matrix.goarch }}.sha256
fi
- name: Upload Binary and Checksum Artifacts
uses: actions/upload-artifact@v3
with:
name: dc_util-${{ matrix.os }}-${{ matrix.goarch }}
path: build/dc_util-${{ matrix.os }}-${{ matrix.goarch }}*

- name: Clean Up Build Directory
run: |
rm -rf build
release:
needs: build-and-release
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, windows, darwin]
goarch: [amd64, arm64]

steps:
- name: Download Binary Artifact
uses: actions/download-artifact@v3
with:
name: dc_util-${{ matrix.os }}-${{ matrix.goarch }}
path: ./release

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.release_version }}
release_name: Release ${{ github.event.inputs.release_version }}
draft: false
prerelease: false

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release
asset_name: dc_util-${{ matrix.os }}-${{ matrix.goarch }}-${{ github.event.inputs.release_version }}
asset_content_type: application/octet-stream

- name: Clean Up Release Directory
run: |
rm -rf release

0 comments on commit f2809e9

Please sign in to comment.