Skip to content

v0.2.10

v0.2.10 #12

Workflow file for this run

name: Release
on:
push:
branches:
- main
jobs:
check:
name: Check commit message
runs-on: ubuntu-latest
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
setup:
name: Setup dependencies
needs: check
if: ${{ needs.check.outputs.commit_message != '' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Set up UPX
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
- name: Install go dependencies
run: go install
build:
name: Build and compress binary
needs: [check, setup]
if: ${{ needs.check.outputs.commit_message != '' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build binary
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
go build -ldflags "-s -w -X main.GITHUB_TOKEN=$GITHUB_TOKEN" -o ./dist/cm-cli_linux_amd64_uncompressed
- name: Compress binary
run: |
upx -f --best --lzma ./dist/cm-cli_linux_amd64_uncompressed -o ./dist/cm-cli_linux_amd64
release:
name: Create release and upload asset
needs: [check, setup, build]
if: ${{ needs.check.outputs.commit_message != '' }}
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.check.outputs.commit_message }}
release_name: Release ${{ needs.check.outputs.commit_message }}
body: |
This release was automatically created by GitHub Actions.
Please refer to [readme](https://github.com/lazco-studio/Component-Manager/blob/main/README.md) for more details.
draft: false
prerelease: false
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/cm-cli_linux_amd64
asset_name: cm-cli_linux_amd64
asset_content_type: application/octet-stream