ci: restore actions/checkout + simplify workflows
- Use actions/checkout@v4 (works with Gitea runner) - Simplified CI: build + vet - Release: auto on push to main, creates/updates "latest" release - Cleaned up archive step 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush <crush@charm.land>
This commit is contained in:
@@ -10,27 +10,17 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
git init
|
||||
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
||||
git fetch origin ${{ github.ref }}
|
||||
git checkout FETCH_HEAD
|
||||
git log --oneline -3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
run: |
|
||||
if ! command -v go &> /dev/null; then
|
||||
wget -q https://go.dev/dl/go1.24.3.linux-amd64.tar.gz
|
||||
sudo tar -C /usr/local -xzf go1.24.3.linux-amd64.tar.gz
|
||||
export PATH=/usr/local/go/bin:$PATH
|
||||
echo "PATH=/usr/local/go/bin:$PATH" >> $GITHUB_ENV
|
||||
fi
|
||||
go version
|
||||
|
||||
- name: Verify source
|
||||
run: ls -la cmd/muyue/ internal/
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
go build -o muyue ./cmd/muyue/
|
||||
|
||||
@@ -9,19 +9,15 @@ jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
git init
|
||||
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
||||
git fetch origin ${{ github.ref }}
|
||||
git checkout FETCH_HEAD
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Go
|
||||
run: |
|
||||
if ! command -v go &> /dev/null; then
|
||||
wget -q https://go.dev/dl/go1.24.3.linux-amd64.tar.gz
|
||||
sudo tar -C /usr/local -xzf go1.24.3.linux-amd64.tar.gz
|
||||
export PATH=/usr/local/go/bin:$PATH
|
||||
echo "PATH=/usr/local/go/bin:$PATH" >> $GITHUB_ENV
|
||||
fi
|
||||
go version
|
||||
@@ -33,43 +29,31 @@ jobs:
|
||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||
echo "version=v${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
||||
echo "Building muyue v${VERSION} (${SHORT_SHA})"
|
||||
|
||||
- name: Build all platforms
|
||||
run: |
|
||||
mkdir -p dist
|
||||
VERSION=${{ steps.info.outputs.version }}
|
||||
SHA=${{ steps.info.outputs.sha }}
|
||||
LDFLAGS="-s -w -X github.com/muyue/muyue/internal/version.Version=${VERSION}-${SHA}"
|
||||
|
||||
echo "Building linux/amd64..."
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${VERSION}-${SHA}" \
|
||||
-o dist/muyue-linux-amd64 ./cmd/muyue/
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o dist/muyue-linux-amd64 ./cmd/muyue/
|
||||
|
||||
echo "Building linux/arm64..."
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${VERSION}-${SHA}" \
|
||||
-o dist/muyue-linux-arm64 ./cmd/muyue/
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS" -o dist/muyue-linux-arm64 ./cmd/muyue/
|
||||
|
||||
echo "Building darwin/amd64..."
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${VERSION}-${SHA}" \
|
||||
-o dist/muyue-darwin-amd64 ./cmd/muyue/
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -o dist/muyue-darwin-amd64 ./cmd/muyue/
|
||||
|
||||
echo "Building darwin/arm64..."
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${VERSION}-${SHA}" \
|
||||
-o dist/muyue-darwin-arm64 ./cmd/muyue/
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -o dist/muyue-darwin-arm64 ./cmd/muyue/
|
||||
|
||||
echo "Building windows/amd64..."
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${VERSION}-${SHA}" \
|
||||
-o dist/muyue-windows-amd64.exe ./cmd/muyue/
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o dist/muyue-windows-amd64.exe ./cmd/muyue/
|
||||
|
||||
echo "Building windows/arm64..."
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${VERSION}-${SHA}" \
|
||||
-o dist/muyue-windows-arm64.exe ./cmd/muyue/
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags="$LDFLAGS" -o dist/muyue-windows-arm64.exe ./cmd/muyue/
|
||||
|
||||
echo "Build complete:"
|
||||
ls -lh dist/
|
||||
@@ -89,23 +73,20 @@ jobs:
|
||||
tar czf muyue-darwin-arm64.tar.gz muyue-darwin-arm64
|
||||
zip muyue-windows-amd64.zip muyue-windows-amd64.exe
|
||||
zip muyue-windows-arm64.zip muyue-windows-arm64.exe
|
||||
rm -f muyue-linux-amd64 muyue-linux-arm64 muyue-darwin-amd64 muyue-darwin-arm64 muyue-windows-amd64.exe muyue-windows-arm64.exe
|
||||
ls -lh
|
||||
ls -lh *.tar.gz *.zip checksums.txt
|
||||
|
||||
- name: Delete old latest release
|
||||
- name: Delete old release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
|
||||
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" "${API}?draft=false&pre-release=false" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*' || true)
|
||||
if [ -n "$RELEASE_ID" ]; then
|
||||
echo "Deleting old release ${RELEASE_ID}..."
|
||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API}/${RELEASE_ID}"
|
||||
fi
|
||||
TAG_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags" | grep -o '"name":"latest"' || true)
|
||||
if [ -n "$TAG_ID" ]; then
|
||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags/latest"
|
||||
fi
|
||||
curl -s -H "Authorization: token ${GITEA_TOKEN}" "${API}" | grep -o '"id":[0-9]*' | while read line; do
|
||||
ID=$(echo "$line" | grep -o '[0-9]*')
|
||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API}/${ID}"
|
||||
echo "Deleted release ${ID}"
|
||||
done
|
||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags/latest" 2>/dev/null || true
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
@@ -115,12 +96,8 @@ jobs:
|
||||
SHA=${{ steps.info.outputs.sha }}
|
||||
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
|
||||
|
||||
COMMIT_LOG=$(git log --oneline -10 | head -10)
|
||||
BODY="## muyue ${VERSION} (${SHA})
|
||||
|
||||
BODY=$(cat <<BODY_END
|
||||
## muyue ${VERSION} (${SHA})
|
||||
|
||||
### Downloads
|
||||
| Platform | File |
|
||||
|----------|------|
|
||||
| Linux x86_64 | muyue-linux-amd64.tar.gz |
|
||||
@@ -130,30 +107,19 @@ jobs:
|
||||
| Windows x86_64 | muyue-windows-amd64.zip |
|
||||
| Windows ARM64 | muyue-windows-arm64.zip |
|
||||
|
||||
### Install (Linux)
|
||||
### Install (Linux amd64)
|
||||
\`\`\`bash
|
||||
curl -sL ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/download/latest/muyue-linux-amd64.tar.gz | tar xz
|
||||
curl -sL ${{ github.server_url }}/${{ github.repository }}/releases/download/latest/muyue-linux-amd64.tar.gz | tar xz
|
||||
chmod +x muyue-linux-amd64
|
||||
sudo mv muyue-linux-amd64 /usr/local/bin/muyue
|
||||
\`\`\`
|
||||
\`\`\`"
|
||||
|
||||
### Recent commits
|
||||
${COMMIT_LOG}
|
||||
BODY_END
|
||||
)
|
||||
|
||||
echo "Creating release..."
|
||||
RESPONSE=$(curl -s -X POST "${API}" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n \
|
||||
--arg tag "latest" \
|
||||
--arg name "muyue ${VERSION} (${SHA})" \
|
||||
--arg body "$BODY" \
|
||||
'{tag_name: $tag, target_commitish: "main", name: $name, body: $body, draft: false, prerelease: false}')")
|
||||
-d "{\"tag_name\":\"latest\",\"target_commitish\":\"main\",\"name\":\"muyue ${VERSION} (${SHA})\",\"body\":$(echo "$BODY" | jq -Rs .),\"draft\":false,\"prerelease\":false}")
|
||||
|
||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
|
||||
echo "Release ID: ${RELEASE_ID}"
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "Failed to create release:"
|
||||
@@ -161,6 +127,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Release ID: ${RELEASE_ID}"
|
||||
UPLOAD_URL="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets"
|
||||
|
||||
for file in dist/*.tar.gz dist/*.zip dist/checksums.txt; do
|
||||
@@ -168,7 +135,7 @@ jobs:
|
||||
echo "Uploading ${filename}..."
|
||||
curl -s -X POST "${UPLOAD_URL}" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@${file};filename=${filename}" | grep -o '"name":"[^"]*"' || echo "uploaded"
|
||||
-F "attachment=@${file};filename=${filename}" > /dev/null
|
||||
done
|
||||
|
||||
echo "Release published!"
|
||||
echo "Release published with 6 binaries!"
|
||||
|
||||
Reference in New Issue
Block a user