Skip to content

add analytics (#21) #14

add analytics (#21)

add analytics (#21) #14

Workflow file for this run

# This workflow will build and test a Golang project
# For more information, see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build and Release
on:
push:
branches: [ "main" ]
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Ensure version is bumped
id: check_version
run: |
# Ensure we have a valid HEAD^
if ! git rev-parse --verify HEAD^ >/dev/null 2>&1; then
echo "Error: Cannot check version bump. Ensure the repository has at least one commit."
exit 1
fi
# Check if the VERSION file in pkg/ was updated
if ! git diff --name-only HEAD^ HEAD | grep -q "pkg/VERSION"; then
echo "Error: pkg/VERSION must be updated to bump the version for a new release."
exit 1
fi
# Read the new version
VERSION=$(cat pkg/VERSION)
echo "version=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build Go project for Linux, macOS (arm64), and Windows
run: |
mkdir -p dist
# Build for Linux (default)
go build -o dist/TimecodeTool-linux-amd64 cmd/TimecodeTool/main.go
# Build for macOS arm64
GOOS=darwin GOARCH=arm64 go build -o dist/TimecodeTool-osx-arm64 cmd/TimecodeTool/main.go
# Build for Windows amd64
GOOS=windows GOARCH=amd64 go build -o dist/TimecodeTool-windows-amd64.exe cmd/TimecodeTool/main.go
- name: Create release tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
- name: Create GitHub Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ env.VERSION }}"
body: "Release version ${{ env.VERSION }}"
files: |
dist/TimecodeTool-linux-amd64
dist/TimecodeTool-osx-arm64
dist/TimecodeTool-windows-amd64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}