ci: migrate workflows to Gitea Actions with self-hosted runner
Replaced GitHub Actions with Gitea-compatible workflows: - CI: build + test + vet on ubuntu-latest (self-hosted runner) - Release: cross-compile 6 binaries (linux/darwin/windows x amd64/arm64) with Gitea API release creation and asset uploads - Removed .github/workflows in favor of .gitea/workflows Requires Gitea secrets: GITEA_TOKEN, GITEA_SERVER, GITEA_REPO 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush <crush@charm.land>
This commit is contained in:
31
.gitea/workflows/ci.yml
Normal file
31
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
run: |
|
||||
wget -q https://go.dev/dl/go1.24.3.linux-amd64.tar.gz
|
||||
sudo rm -rf /usr/local/go
|
||||
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
|
||||
go version
|
||||
|
||||
- name: Build
|
||||
run: go build -o muyue ./cmd/muyue/
|
||||
|
||||
- name: Test
|
||||
run: go test ./... -v
|
||||
|
||||
- name: Vet
|
||||
run: go vet ./...
|
||||
139
.gitea/workflows/release.yml
Normal file
139
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,139 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Go
|
||||
run: |
|
||||
wget -q https://go.dev/dl/go1.24.3.linux-amd64.tar.gz
|
||||
sudo rm -rf /usr/local/go
|
||||
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
|
||||
go version
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build all platforms
|
||||
run: |
|
||||
mkdir -p dist
|
||||
VERSION=${{ steps.version.outputs.VERSION }}
|
||||
|
||||
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}" \
|
||||
-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}" \
|
||||
-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}" \
|
||||
-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}" \
|
||||
-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}" \
|
||||
-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}" \
|
||||
-o dist/muyue-windows-arm64.exe ./cmd/muyue/
|
||||
|
||||
echo "Build complete:"
|
||||
ls -lh dist/
|
||||
|
||||
- name: Create checksums
|
||||
run: |
|
||||
cd dist
|
||||
sha256sum * > checksums.txt
|
||||
cat checksums.txt
|
||||
|
||||
- name: Create archives
|
||||
run: |
|
||||
cd dist
|
||||
tar czf muyue-linux-amd64.tar.gz muyue-linux-amd64
|
||||
tar czf muyue-linux-arm64.tar.gz muyue-linux-arm64
|
||||
tar czf muyue-darwin-amd64.tar.gz muyue-darwin-amd64
|
||||
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
|
||||
ls -lh *.tar.gz *.zip checksums.txt
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
run: |
|
||||
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
||||
if [ -z "$PREVIOUS_TAG" ]; then
|
||||
echo "CHANGELOG=Initial release of muyue v0.1.0" >> $GITHUB_OUTPUT
|
||||
else
|
||||
CHANGELOG=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s" --no-merges)
|
||||
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create Gitea Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_SERVER: ${{ secrets.GITEA_SERVER }}
|
||||
GITEA_REPO: ${{ secrets.GITEA_REPO }}
|
||||
run: |
|
||||
VERSION=${{ steps.version.outputs.VERSION }}
|
||||
REPO_API="${GITEA_SERVER}/api/v1/repos/${GITEA_REPO}/releases"
|
||||
|
||||
echo "Creating release ${VERSION}..."
|
||||
|
||||
RESPONSE=$(curl -s -X POST "${REPO_API}" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"tag_name\": \"${VERSION}\",
|
||||
\"target_commitish\": \"main\",
|
||||
\"name\": \"muyue ${VERSION}\",
|
||||
\"body\": \"## Changes\n${{ steps.changelog.outputs.CHANGELOG }}\n\n## Binaries\n- Linux amd64: muyue-linux-amd64.tar.gz\n- Linux arm64: muyue-linux-arm64.tar.gz\n- macOS Intel: muyue-darwin-amd64.tar.gz\n- macOS Apple Silicon: muyue-darwin-arm64.tar.gz\n- Windows amd64: muyue-windows-amd64.zip\n- Windows arm64: muyue-windows-arm64.zip\n\n## Checksums\nSee checksums.txt\",
|
||||
\"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"
|
||||
echo "$RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UPLOAD_URL="${GITEA_SERVER}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}/assets"
|
||||
|
||||
for file in dist/muyue-linux-amd64.tar.gz dist/muyue-linux-arm64.tar.gz dist/muyue-darwin-amd64.tar.gz dist/muyue-darwin-arm64.tar.gz dist/muyue-windows-amd64.zip dist/muyue-windows-arm64.zip dist/checksums.txt; do
|
||||
filename=$(basename "$file")
|
||||
echo "Uploading ${filename}..."
|
||||
curl -s -X POST "${UPLOAD_URL}" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@${file};filename=${filename}" | grep -o '"name":"[^"]*"'
|
||||
done
|
||||
|
||||
echo "Release ${VERSION} published!"
|
||||
43
.github/workflows/ci.yml
vendored
43
.github/workflows/ci.yml
vendored
@@ -1,43 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
|
||||
- name: Build
|
||||
run: go build -o muyue ./cmd/muyue/
|
||||
|
||||
- name: Test
|
||||
run: go test ./... -v
|
||||
|
||||
- name: Vet
|
||||
run: go vet ./...
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: latest
|
||||
156
.github/workflows/release.yml
vendored
156
.github/workflows/release.yml
vendored
@@ -1,156 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build all platforms
|
||||
run: |
|
||||
mkdir -p dist
|
||||
|
||||
# Linux amd64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${{ steps.version.outputs.VERSION }}" \
|
||||
-o dist/muyue-linux-amd64 ./cmd/muyue/
|
||||
|
||||
# Linux arm64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${{ steps.version.outputs.VERSION }}" \
|
||||
-o dist/muyue-linux-arm64 ./cmd/muyue/
|
||||
|
||||
# macOS amd64
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${{ steps.version.outputs.VERSION }}" \
|
||||
-o dist/muyue-darwin-amd64 ./cmd/muyue/
|
||||
|
||||
# macOS arm64 (Apple Silicon)
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${{ steps.version.outputs.VERSION }}" \
|
||||
-o dist/muyue-darwin-arm64 ./cmd/muyue/
|
||||
|
||||
# Windows amd64
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${{ steps.version.outputs.VERSION }}" \
|
||||
-o dist/muyue-windows-amd64.exe ./cmd/muyue/
|
||||
|
||||
# Windows arm64
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build \
|
||||
-ldflags="-s -w -X github.com/muyue/muyue/internal/version.Version=${{ steps.version.outputs.VERSION }}" \
|
||||
-o dist/muyue-windows-arm64.exe ./cmd/muyue/
|
||||
|
||||
- name: Create checksums
|
||||
run: |
|
||||
cd dist
|
||||
sha256sum * > checksums.txt
|
||||
cat checksums.txt
|
||||
|
||||
- name: Create archives
|
||||
run: |
|
||||
cd dist
|
||||
|
||||
# Linux amd64
|
||||
tar czf muyue-linux-amd64.tar.gz muyue-linux-amd64
|
||||
|
||||
# Linux arm64
|
||||
tar czf muyue-linux-arm64.tar.gz muyue-linux-arm64
|
||||
|
||||
# macOS amd64
|
||||
tar czf muyue-darwin-amd64.tar.gz muyue-darwin-amd64
|
||||
|
||||
# macOS arm64
|
||||
tar czf muyue-darwin-arm64.tar.gz muyue-darwin-arm64
|
||||
|
||||
# Windows amd64
|
||||
zip muyue-windows-amd64.zip muyue-windows-amd64.exe
|
||||
|
||||
# Windows arm64
|
||||
zip muyue-windows-arm64.zip muyue-windows-arm64.exe
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
run: |
|
||||
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
||||
if [ -z "$PREVIOUS_TAG" ]; then
|
||||
echo "CHANGELOG=Initial release of muyue." >> $GITHUB_OUTPUT
|
||||
else
|
||||
CHANGELOG=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s" --no-merges)
|
||||
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.VERSION }}
|
||||
name: muyue ${{ steps.version.outputs.VERSION }}
|
||||
body: |
|
||||
## Changes
|
||||
${{ steps.changelog.outputs.CHANGELOG }}
|
||||
|
||||
## Installation
|
||||
|
||||
### Linux (amd64)
|
||||
```bash
|
||||
curl -sL https://github.com/$(echo ${{ github.repository }} | tr -d ' ')/releases/download/${{ steps.version.outputs.VERSION }}/muyue-linux-amd64.tar.gz | tar xz
|
||||
chmod +x muyue-linux-amd64
|
||||
sudo mv muyue-linux-amd64 /usr/local/bin/muyue
|
||||
```
|
||||
|
||||
### Linux (arm64)
|
||||
```bash
|
||||
curl -sL https://github.com/$(echo ${{ github.repository }} | tr -d ' ')/releases/download/${{ steps.version.outputs.VERSION }}/muyue-linux-arm64.tar.gz | tar xz
|
||||
chmod +x muyue-linux-arm64
|
||||
sudo mv muyue-linux-arm64 /usr/local/bin/muyue
|
||||
```
|
||||
|
||||
### macOS (Apple Silicon)
|
||||
```bash
|
||||
curl -sL https://github.com/$(echo ${{ github.repository }} | tr -d ' ')/releases/download/${{ steps.version.outputs.VERSION }}/muyue-darwin-arm64.tar.gz | tar xz
|
||||
chmod +x muyue-darwin-arm64
|
||||
sudo mv muyue-darwin-arm64 /usr/local/bin/muyue
|
||||
```
|
||||
|
||||
### macOS (Intel)
|
||||
```bash
|
||||
curl -sL https://github.com/$(echo ${{ github.repository }} | tr -d ' ')/releases/download/${{ steps.version.outputs.VERSION }}/muyue-darwin-amd64.tar.gz | tar xz
|
||||
chmod +x muyue-darwin-amd64
|
||||
sudo mv muyue-darwin-amd64 /usr/local/bin/muyue
|
||||
```
|
||||
|
||||
### Windows
|
||||
Download `muyue-windows-amd64.zip` from the assets below.
|
||||
|
||||
## Checksums
|
||||
See `checksums.txt` in the release assets.
|
||||
|
||||
files: |
|
||||
dist/muyue-linux-amd64.tar.gz
|
||||
dist/muyue-linux-arm64.tar.gz
|
||||
dist/muyue-darwin-amd64.tar.gz
|
||||
dist/muyue-darwin-arm64.tar.gz
|
||||
dist/muyue-windows-amd64.zip
|
||||
dist/muyue-windows-arm64.zip
|
||||
dist/checksums.txt
|
||||
draft: false
|
||||
prerelease: false
|
||||
Reference in New Issue
Block a user