Create release action for sda-admin
#4
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: Release sda-admin | |
on: | |
merge_group: | |
pull_request: | |
paths: | |
- 'sda-admin/.version' | |
# types: [ closed ] | |
workflow_dispatch: | |
jobs: | |
release_sda_admin: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- name: Get version tag | |
run: | | |
VERSION=$(cat sda-admin/.version) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create release | |
uses : softprops/action-gh-release@v2 | |
with: | |
tag_name: "sda-admin-${{ env.VERSION }}" | |
package_sda_admin: | |
needs: [release_sda_admin] | |
permissions: | |
contents: read | |
packages: write | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# List of GOOS and GOARCH pairs from `go tool dist list` | |
goosarch: | |
- "linux/amd64" | |
- "windows/amd64" | |
- "darwin/amd64" | |
- "darwin/arm64" | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '>=1.22' | |
id: go | |
- name: Get dependencies | |
run: | | |
cd sda-admin | |
go get -v -t -d ./... | |
if [ -f Gopkg.toml ]; then | |
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | |
dep ensure | |
fi | |
- name: Get OS and arch info | |
run: | | |
GOOSARCH=${{matrix.goosarch}} | |
GOOS=${GOOSARCH%/*} | |
GOARCH=${GOOSARCH#*/} | |
VERSION=$(cat sda-admin/.version) | |
BINARY_NAME=sda-admin_${VERSION}_${GOOS}_${GOARCH} | |
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV | |
echo "GOOS=$GOOS" >> $GITHUB_ENV | |
echo "GOARCH=$GOARCH" >> $GITHUB_ENV | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
cd sda-admin | |
go build -o "$BINARY_NAME" -v -ldflags="-s -w -X 'main.version=$VERSION'" | |
tar -czf "$BINARY_NAME.tgz" "$BINARY_NAME" ../LICENSE | |
- name: Upload artifact | |
run: | | |
cd sda-admin | |
gh release upload "sda-admin-${{ env.VERSION }}" ${{ env.BINARY_NAME.tgz }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |