chore: simplify build workflow for v1.3
This commit is contained in:
parent
8f783b162c
commit
8a804eec0c
108
.github/workflows/deploy-linux.yml
vendored
108
.github/workflows/deploy-linux.yml
vendored
@ -11,13 +11,6 @@ on:
|
|||||||
description: 'Version to build (leave empty for auto)'
|
description: 'Version to build (leave empty for auto)'
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
create_release:
|
|
||||||
description: 'Create GitHub Release'
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
type: boolean
|
|
||||||
release:
|
|
||||||
types: [ published ]
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@ -27,109 +20,46 @@ jobs:
|
|||||||
name: Build Linux Binary
|
name: Build Linux Binary
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
outputs:
|
|
||||||
version: ${{ steps.version.outputs.version }}
|
|
||||||
binary_name: ${{ steps.build.outputs.binary_name }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.23.3'
|
go-version: '1.23.3'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Get version information
|
- name: Build
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
if [ "${{ github.event_name }}" = "release" ]; then
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
|
||||||
elif [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref_type }}" = "tag" ]; then
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
|
||||||
elif [ -n "${{ github.event.inputs.version }}" ]; then
|
|
||||||
VERSION="${{ github.event.inputs.version }}"
|
|
||||||
else
|
|
||||||
VERSION=$(git describe --tags --always --dirty)
|
|
||||||
fi
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "BUILD_TIME=$(date -u +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV
|
|
||||||
echo "GIT_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build binary
|
|
||||||
id: build
|
|
||||||
env:
|
env:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
run: |
|
run: |
|
||||||
BINARY_NAME_WITH_VERSION="ppanel-server-${{ env.VERSION }}-linux-amd64"
|
VERSION=${{ github.event.inputs.version }}
|
||||||
echo "binary_name=$BINARY_NAME_WITH_VERSION" >> $GITHUB_OUTPUT
|
if [ -z "$VERSION" ]; then
|
||||||
|
VERSION=$(git describe --tags --always --dirty)
|
||||||
|
fi
|
||||||
|
|
||||||
go build \
|
echo "Building ppanel-server $VERSION"
|
||||||
-ldflags "-s -w \
|
go build -ldflags "-s -w -X main.Version=$VERSION" -o ppanel-server ./ppanel.go
|
||||||
-X 'github.com/perfect-panel/server/pkg/constant.Version=${{ env.VERSION }}' \
|
tar -czf ppanel-server-${VERSION}-linux-amd64.tar.gz ppanel-server
|
||||||
-X 'github.com/perfect-panel/server/pkg/constant.BuildTime=${{ env.BUILD_TIME }}' \
|
sha256sum ppanel-server ppanel-server-${VERSION}-linux-amd64.tar.gz > checksum.txt
|
||||||
-X 'github.com/perfect-panel/server/pkg/constant.GitCommit=${{ env.GIT_COMMIT }}'" \
|
|
||||||
-o "$BINARY_NAME_WITH_VERSION" \
|
|
||||||
./ppanel.go
|
|
||||||
|
|
||||||
- name: Generate checksum
|
- name: Upload artifacts
|
||||||
run: |
|
|
||||||
sha256sum "${{ steps.build.outputs.binary_name }}" > checksum.txt
|
|
||||||
echo "Checksum: $(cat checksum.txt)"
|
|
||||||
|
|
||||||
- name: Upload build artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ppanel-server-linux-amd64
|
name: ppanel-server-linux-amd64
|
||||||
path: |
|
path: |
|
||||||
${{ steps.build.outputs.binary_name }}
|
ppanel-server
|
||||||
|
ppanel-server-*-linux-amd64.tar.gz
|
||||||
checksum.txt
|
checksum.txt
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
- name: Create and Upload to GitHub Release
|
- name: Create Release
|
||||||
if: github.event_name == 'release' || github.event.inputs.create_release == 'true' || (github.event_name == 'push' && github.ref_type == 'tag')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
# Create release if it doesn't exist
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
if [ "${{ github.event.inputs.create_release }}" = "true" ] && [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
gh release create $VERSION --title "PPanel Server $VERSION" || true
|
||||||
echo "Creating release for ${{ env.VERSION }}"
|
gh release upload $VERSION ppanel-server-${VERSION}-linux-amd64.tar.gz checksum.txt
|
||||||
gh release create ${{ env.VERSION }} \
|
|
||||||
--title "PPanel Server ${{ env.VERSION }}" \
|
|
||||||
--notes "Release ${{ env.VERSION }}" \
|
|
||||||
--latest
|
|
||||||
elif [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref_type }}" = "tag" ]; then
|
|
||||||
echo "Creating release for tag ${{ env.VERSION }}"
|
|
||||||
gh release create ${{ env.VERSION }} \
|
|
||||||
--title "PPanel Server ${{ env.VERSION }}" \
|
|
||||||
--notes "Release ${{ env.VERSION }}" \
|
|
||||||
--latest
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Uploading binaries to release ${{ env.VERSION }}"
|
|
||||||
gh release upload ${{ env.VERSION }} \
|
|
||||||
${{ steps.build.outputs.binary_name }} \
|
|
||||||
checksum.txt
|
|
||||||
|
|
||||||
- name: Create summary
|
|
||||||
run: |
|
|
||||||
echo "## 📦 Build Summary" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "**Binary:** ${{ steps.build.outputs.binary_name }}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "**Version:** ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "**Size:** $(du -h ${{ steps.build.outputs.binary_name }} | cut -f1)" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "**Checksum:** $(cat checksum.txt)" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "### 📥 Download" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "Go to Actions → Artifacts → \`ppanel-server-linux-amd64\` to download" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "### 🚀 Usage" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "1. Download the binary" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "2. Extract from tar.gz" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "3. Run: chmod +x ppanel-server-* && ./ppanel-server-* run --config etc/ppanel.yaml" >> $GITHUB_STEP_SUMMARY
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user