command updates! #49
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 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22.5' | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Build binaries | |
run: | | |
mkdir -p dist | |
GOOS=linux GOARCH=amd64 go build -o dist/commandtrein-linux | |
GOOS=darwin GOARCH=amd64 go build -o dist/commandtrein-macos | |
GOOS=windows GOARCH=amd64 go build -o dist/commandtrein-windows | |
- name: Extract Version from main.go | |
id: get_version | |
run: | | |
VERSION=$(grep -oP '(?<=Version = ")[^"]*' cmd/version.go) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Get Latest Commit Info | |
id: commit_info | |
run: | | |
echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
echo "COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Linux Binary | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/commandtrein-linux | |
asset_name: commandtrein-linux | |
asset_content_type: application/octet-stream | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload macOS Binary | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/commandtrein-macos | |
asset_name: commandtrein-macos | |
asset_content_type: application/octet-stream | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Windows Binary | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/commandtrein-windows | |
asset_name: commandtrein.exe | |
asset_content_type: application/octet-stream | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |