Skip to content

v0.2.9

v0.2.9 #11

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, compress binary and create release
needs: [check, setup]
if: ${{ needs.check.outputs.commit_message != '' }}
runs-on: ubuntu-latest
permissions: write-all
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
# - 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 is an automated release.
# draft: false
# prerelease: false
- name: Create release
id: create_release
uses: CupOfTea696/gh-action-auto-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: 🎉 Release ${{ needs.check.outputs.commit_message }}
tag: ${{ needs.check.outputs.commit_message }}
draft: 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