Skip to content

Merge pull request #1 from hiddify/release-please--branches--main #3

Merge pull request #1 from hiddify/release-please--branches--main

Merge pull request #1 from hiddify/release-please--branches--main #3

name: Release Please
on:
push:
branches: [main]
workflow_dispatch:
inputs:
force_release:
description: 'Force create a release PR even without conventional commits'
type: boolean
default: false
release_as:
description: 'Force release as specific version (e.g., 1.0.0). Leave empty for auto.'
type: string
default: ''
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- name: Release Please
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-as: ${{ inputs.release_as || '' }}
build:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64, arm, 386]
include:
- goarch: arm
goarm: 7
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
run: |
ARCH=${{ matrix.goarch }}
if [ "$ARCH" = "arm" ]; then
ARCH="armv7"
fi
VERSION=${{ needs.release-please.outputs.tag_name }}
OUTPUT_NAME="dnstm-${{ matrix.goos }}-${ARCH}"
go build -ldflags="-s -w -X main.Version=${VERSION} -X main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o "${OUTPUT_NAME}" .
chmod +x "${OUTPUT_NAME}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dnstm-${{ matrix.goos }}-${{ matrix.goarch == 'arm' && 'armv7' || matrix.goarch }}
path: dnstm-*
upload-assets:
needs: [release-please, build]
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release files
run: |
mkdir -p release
find artifacts -type f -name 'dnstm-*' -exec cp {} release/ \;
cd release
for f in dnstm-*; do
sha256sum "$f" > "$f.sha256"
done
- name: Upload to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ needs.release-please.outputs.tag_name }} release/* --repo ${{ github.repository }}