75 lines
2.2 KiB
YAML
75 lines
2.2 KiB
YAML
name: Build matrix binaries and push to external repo
|
|
run-name: Build ${{ github.ref_name }} of ${{ github.repository }}
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*' # match semver only, e.g. v1.2.3
|
|
|
|
|
|
jobs:
|
|
|
|
prepare_release:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Checkout
|
|
id: checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Extract Go version (from go.mod)
|
|
id: extract_go_version
|
|
run: | # Read Go version from go.mod and save it to the VER_GO environment variable.
|
|
VER_GO=$(grep -m 1 go go.mod | cut -d\ -f2)
|
|
echo "VER_GO=$VER_GO" >> $GITHUB_ENV
|
|
|
|
- name: Extract PPanel(api) version (from pkg/constant/types.go)
|
|
id: extract_api_version
|
|
run: | # Read API version from pkg/constant/types.go and save it to the VER_API environment variable.
|
|
VER_API=$(grep -oP '(?<=const Version = \")[0-9]+\.[0-9]+\.[0-9]+' pkg/constant/version.go)
|
|
echo "VER_API=$VER_API" >> $GITHUB_ENV
|
|
|
|
- name: Create release in destination repo
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.REL_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref_name }}
|
|
release_name: PPanel Server ${{ github.ref_name }}
|
|
body: |
|
|
PPanel Server ${{ github.ref_name }}
|
|
PPanel API v${{ env.VER_API }}
|
|
draft: false
|
|
prerelease: false
|
|
owner: ${{ vars.REL_OWNER }}
|
|
repo: ${{ vars.REL_REPO }}
|
|
commitish: master
|
|
|
|
build_matrix:
|
|
needs: prepare_release
|
|
strategy:
|
|
matrix:
|
|
goos: [linux, windows, darwin]
|
|
goarch: [amd64, arm64]
|
|
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Checkout
|
|
id: checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build binaries and push to external repo
|
|
id: build_and_push
|
|
uses: wangyoucao577/go-release-action@v1
|
|
with:
|
|
github_token: ${{ secrets.REL_TOKEN }}
|
|
goos: ${{ matrix.goos }}
|
|
goarch: ${{ matrix.goarch }}
|
|
goversion: ${{ env.VER_GO }}
|
|
binary_name: ppanel-server
|
|
pre_command: export CGO_ENABLED=0
|
|
ldflags: -s -w
|
|
release_repo: ${{ vars.REL_OWNER }}/${{ vars.REL_REPO }}
|
|
extra_files: LICENSE etc
|
|
md5sum: false
|