refactor(workflow): consolidate build steps and remove redundant release processes
- Merged the Linux build job into a single 'build' job for improved clarity and efficiency. - Removed redundant version retrieval steps from both Linux and macOS workflows, streamlining the release process. - Updated dependencies and artifact handling to ensure compatibility with the new workflow structure. - Enhanced the macOS workflow to trigger on version tags, improving version management during releases. Made-with: Cursor
This commit is contained in:
parent
128d9b174f
commit
d6e5afd26b
3 changed files with 117 additions and 121 deletions
65
.github/workflows/release-linux.yml
vendored
65
.github/workflows/release-linux.yml
vendored
|
|
@ -19,9 +19,8 @@ env:
|
|||
jobs:
|
||||
# ===================================================================
|
||||
# Build Linux Binaries (amd64 + arm64)
|
||||
# Uses the yaoapp/yao-build container which has all cross-compile deps.
|
||||
# ===================================================================
|
||||
build-linux:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: yaoapp/yao-build:1.0.0
|
||||
|
|
@ -45,18 +44,6 @@ jobs:
|
|||
/app/build.sh
|
||||
ls -l /data
|
||||
|
||||
- name: Get Version
|
||||
id: version
|
||||
run: |
|
||||
if [ -n "${{ github.event.inputs.version }}" ]; then
|
||||
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
|
||||
elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
||||
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
VERSION=$(cat share/const.go | grep 'const VERSION' | awk '{print $4}' | sed 's/"//g')
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Push To R2
|
||||
run: |
|
||||
for file in /data/*; do
|
||||
|
|
@ -70,59 +57,11 @@ jobs:
|
|||
name: yao-linux
|
||||
path: /data/*
|
||||
|
||||
# ===================================================================
|
||||
# GitHub Release + Tag
|
||||
# ===================================================================
|
||||
release:
|
||||
needs: build-linux
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get Version
|
||||
id: version
|
||||
run: |
|
||||
if [ -n "${{ github.event.inputs.version }}" ]; then
|
||||
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
|
||||
elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
||||
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
VERSION=$(cat share/const.go | grep 'const VERSION' | awk '{print $4}' | sed 's/"//g')
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Download Linux Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: yao-linux
|
||||
path: dist
|
||||
|
||||
- name: List Artifacts
|
||||
run: ls -lh dist/
|
||||
|
||||
- name: Create Tag (if manual dispatch)
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
git config user.name "github-actions"
|
||||
git config user.email "github-actions@github.com"
|
||||
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}" || true
|
||||
git push origin "v${{ steps.version.outputs.version }}" || true
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: v${{ steps.version.outputs.version }}
|
||||
name: Yao v${{ steps.version.outputs.version }}
|
||||
files: dist/*
|
||||
generate_release_notes: true
|
||||
|
||||
# ===================================================================
|
||||
# Docker Images (multi-platform linux/amd64 + linux/arm64)
|
||||
# Builds after R2 upload so Dockerfiles can curl binaries from R2.
|
||||
# ===================================================================
|
||||
docker:
|
||||
needs: build-linux
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
|
|
|
|||
63
.github/workflows/release-macos.yml
vendored
63
.github/workflows/release-macos.yml
vendored
|
|
@ -6,6 +6,9 @@ on:
|
|||
version:
|
||||
description: "Release version (e.g. 1.0.0 or 1.0.0-alpha). Leave empty to read from share/const.go."
|
||||
required: false
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
|
@ -107,6 +110,8 @@ jobs:
|
|||
run: |
|
||||
if [ -n "${{ github.event.inputs.version }}" ]; then
|
||||
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
|
||||
elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
||||
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
VERSION=$(cat share/const.go | grep 'const VERSION' | awk '{print $4}' | sed 's/"//g')
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
|
|
@ -155,7 +160,6 @@ jobs:
|
|||
done
|
||||
|
||||
- name: Prepare Output and Checksums
|
||||
id: output
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
for ARCH in arm64 amd64; do
|
||||
|
|
@ -167,7 +171,6 @@ jobs:
|
|||
mkdir -p /tmp/checksums
|
||||
shasum -a 256 /tmp/yao-output-arm64/yao | awk '{print $1" yao"}' > /tmp/checksums/yao-darwin-arm64.sha256
|
||||
shasum -a 256 /tmp/yao-output-amd64/yao | awk '{print $1" yao"}' > /tmp/checksums/yao-darwin-amd64.sha256
|
||||
echo "=== Checksums ==="
|
||||
cat /tmp/checksums/*.sha256
|
||||
|
||||
- name: Upload arm64 Binary
|
||||
|
|
@ -193,59 +196,3 @@ jobs:
|
|||
with:
|
||||
name: yao-darwin-amd64-sha256
|
||||
path: /tmp/checksums/yao-darwin-amd64.sha256
|
||||
|
||||
# ===================================================================
|
||||
# GitHub Release (if version provided)
|
||||
# ===================================================================
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.inputs.version != ''
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download arm64 Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: yao-darwin-arm64
|
||||
path: dist/arm64
|
||||
|
||||
- name: Download amd64 Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: yao-darwin-amd64
|
||||
path: dist/amd64
|
||||
|
||||
- name: Download Checksums
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: yao-darwin-*-sha256
|
||||
path: dist/checksums
|
||||
merge-multiple: true
|
||||
|
||||
- name: Prepare Release Files
|
||||
run: |
|
||||
VERSION="${{ github.event.inputs.version }}"
|
||||
mkdir -p release
|
||||
cp dist/arm64/yao "release/yao-${VERSION}-darwin-arm64"
|
||||
cp dist/amd64/yao "release/yao-${VERSION}-darwin-amd64"
|
||||
cp dist/checksums/*.sha256 release/
|
||||
chmod +x release/yao-*
|
||||
ls -la release/
|
||||
|
||||
- name: Create Tag
|
||||
run: |
|
||||
git config user.name "github-actions"
|
||||
git config user.email "github-actions@github.com"
|
||||
git tag -a "v${{ github.event.inputs.version }}-macos" -m "Release v${{ github.event.inputs.version }} (macOS)" || true
|
||||
git push origin "v${{ github.event.inputs.version }}-macos" || true
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: v${{ github.event.inputs.version }}-macos
|
||||
name: Yao v${{ github.event.inputs.version }} (macOS)
|
||||
files: release/*
|
||||
generate_release_notes: true
|
||||
draft: true
|
||||
|
|
|
|||
110
.github/workflows/release.yml
vendored
Normal file
110
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Release Linux", "Release macOS"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
# ===================================================================
|
||||
# Wait for both workflows to succeed, then create a unified release
|
||||
# ===================================================================
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
startsWith(github.event.workflow_run.head_branch, 'v')
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get Version
|
||||
id: version
|
||||
run: |
|
||||
TAG="${{ github.event.workflow_run.head_branch }}"
|
||||
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Wait for Both Workflows
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
TAG="${{ steps.version.outputs.tag }}"
|
||||
echo "Waiting for both Release Linux and Release macOS to complete for $TAG..."
|
||||
|
||||
for i in $(seq 1 60); do
|
||||
LINUX_STATUS=$(gh run list --workflow="Release Linux" --branch="$TAG" --limit=1 --json conclusion --jq '.[0].conclusion // "pending"')
|
||||
MACOS_STATUS=$(gh run list --workflow="Release macOS" --branch="$TAG" --limit=1 --json conclusion --jq '.[0].conclusion // "pending"')
|
||||
|
||||
echo "Attempt $i: Linux=$LINUX_STATUS macOS=$MACOS_STATUS"
|
||||
|
||||
if [ "$LINUX_STATUS" = "success" ] && [ "$MACOS_STATUS" = "success" ]; then
|
||||
echo "Both workflows completed successfully."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$LINUX_STATUS" = "failure" ] || [ "$MACOS_STATUS" = "failure" ]; then
|
||||
echo "::error::One or both workflows failed (Linux=$LINUX_STATUS macOS=$MACOS_STATUS)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 60
|
||||
done
|
||||
|
||||
echo "::error::Timed out waiting for workflows"
|
||||
exit 1
|
||||
|
||||
- name: Download Linux Artifacts
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
TAG="${{ steps.version.outputs.tag }}"
|
||||
LINUX_RUN_ID=$(gh run list --workflow="Release Linux" --branch="$TAG" --limit=1 --json databaseId --jq '.[0].databaseId')
|
||||
mkdir -p dist/linux
|
||||
gh run download "$LINUX_RUN_ID" --name yao-linux --dir dist/linux
|
||||
|
||||
- name: Download macOS Artifacts
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
TAG="${{ steps.version.outputs.tag }}"
|
||||
MACOS_RUN_ID=$(gh run list --workflow="Release macOS" --branch="$TAG" --limit=1 --json databaseId --jq '.[0].databaseId')
|
||||
mkdir -p dist/macos
|
||||
gh run download "$MACOS_RUN_ID" --name yao-darwin-arm64 --dir dist/macos
|
||||
gh run download "$MACOS_RUN_ID" --name yao-darwin-amd64 --dir dist/macos
|
||||
gh run download "$MACOS_RUN_ID" --pattern "yao-darwin-*-sha256" --dir dist/macos
|
||||
|
||||
- name: Prepare Release Files
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
mkdir -p release
|
||||
|
||||
cp dist/linux/* release/ 2>/dev/null || true
|
||||
|
||||
if [ -f dist/macos/yao-darwin-arm64/yao ]; then
|
||||
cp dist/macos/yao-darwin-arm64/yao "release/yao-${VERSION}-darwin-arm64"
|
||||
elif [ -f dist/macos/yao ]; then
|
||||
cp dist/macos/yao "release/yao-${VERSION}-darwin-arm64"
|
||||
fi
|
||||
|
||||
if [ -f dist/macos/yao-darwin-amd64/yao ]; then
|
||||
cp dist/macos/yao-darwin-amd64/yao "release/yao-${VERSION}-darwin-amd64"
|
||||
fi
|
||||
|
||||
find dist/macos -name "*.sha256" -exec cp {} release/ \;
|
||||
|
||||
chmod +x release/yao-* 2>/dev/null || true
|
||||
echo "=== Release files ==="
|
||||
ls -lh release/
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.tag }}
|
||||
name: Yao v${{ steps.version.outputs.version }}
|
||||
files: release/*
|
||||
generate_release_notes: true
|
||||
Loading…
Add table
Reference in a new issue