Skip to content

Merge pull request #8 from Lazco-Studio/blacksmith-migration-f96647b #70

Merge pull request #8 from Lazco-Studio/blacksmith-migration-f96647b

Merge pull request #8 from Lazco-Studio/blacksmith-migration-f96647b #70

Workflow file for this run

name: Release
on:
push:
branches:
- main
jobs:
check:
name: Check commit message
runs-on: blacksmith-4vcpu-ubuntu-2204
outputs:
commit_message: ${{ steps.check_commit_message.outputs.commit_message }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check commit message
id: check_commit_message
run: |
commit_message=$(git log --format=%B -n 1 ${{ github.sha }})
if [[ $commit_message =~ ^v[0-9]+\.[0-9]+\.[0-9] ]]; then
echo "Commit message matches version format."
echo "commit_message=$commit_message" >> "$GITHUB_OUTPUT"
else
echo "Commit message does not match version format. Skipping release."
fi
build:
name: Build and compress binary
needs: [check]
if: ${{ needs.check.outputs.commit_message != '' }}
runs-on: blacksmith-4vcpu-ubuntu-2204
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create necessary directory
run: |
mkdir -p dist/uncompressed
mkdir -p dist/compressed
- name: "Install go dependencies"
run: |
go install
- name: Build binary for linux/amd64
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.GITHUB_TOKEN=$GITHUB_TOKEN" -o ./dist/uncompressed/cm-cli_linux_amd64
- name: Build binary for darwin/amd64
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.GITHUB_TOKEN=$GITHUB_TOKEN" -o ./dist/uncompressed/cm-cli_darwin_amd64
- name: Build binary for windows/amd64
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.GITHUB_TOKEN=$GITHUB_TOKEN" -o ./dist/uncompressed/cm-cli_windows_amd64.exe
- name: Install UPX
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
- name: Compress binary for linux/amd64
run: |
upx -f --best --lzma ./dist/uncompressed/cm-cli_linux_amd64 -o ./dist/compressed/cm-cli_linux_amd64
- name: Compress binary for darwin/amd64
run: |
upx -f --best --lzma ./dist/uncompressed/cm-cli_darwin_amd64 -o ./dist/compressed/cm-cli_darwin_amd64 --force-macos
- name: Compress binary for windows/amd64
run: |
upx -f --best --lzma ./dist/uncompressed/cm-cli_windows_amd64.exe -o ./dist/compressed/cm-cli_windows_amd64.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cm-cli
path: dist
release:
name: Create release and upload asset
needs: [check, build]
if: ${{ needs.check.outputs.commit_message != '' }}
runs-on: blacksmith-4vcpu-ubuntu-2204
permissions: write-all
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: cm-cli
path: dist
- name: Create release and upload asset
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.check.outputs.commit_message }}
name: 🎉 Release ${{ needs.check.outputs.commit_message }}
body: |
Please follow the [installation guide](https://github.com/lazco-studio/Component-Manager?tab=readme-ov-file#installation) to install the latest version of the Component Manager.
generate_release_notes: true
append_body: true
make_latest: "true"
files: |
dist/compressed/cm-cli_linux_amd64
dist/compressed/cm-cli_darwin_amd64
dist/compressed/cm-cli_windows_amd64.exe
- name: Delete artifact
uses: geekyeggo/delete-artifact@v5
with:
name: cm-cli