Skip to content

Add GitHub Actions cross-platform build workflow #1

Add GitHub Actions cross-platform build workflow

Add GitHub Actions cross-platform build workflow #1

Workflow file for this run

name: Build
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.goos }}-${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build binary
shell: bash
run: |
set -euo pipefail
mkdir -p dist
ext=""
if [[ "${{ matrix.goos }}" == "windows" ]]; then
ext=".exe"
fi
out="ticktick-${{ matrix.goos }}-${{ matrix.goarch }}${ext}"
GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" CGO_ENABLED=0 \
go build -trimpath -ldflags="-s -w" -o "dist/${out}" ./cmd/ticktick
(cd dist && sha256sum "${out}" > "${out}.sha256")
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ticktick-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dist/ticktick-${{ matrix.goos }}-${{ matrix.goarch }}*