Compare commits
2 Commits
6578e93a16
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 30f4ebbd6d | |||
| 17a0346aa8 |
@@ -6,7 +6,7 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
@@ -65,68 +65,41 @@ jobs:
|
||||
fi
|
||||
go build -ldflags "-X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME}" \
|
||||
-o bin/${OUTPUT_NAME} ./cmd/safelineApi
|
||||
echo "BINARY_PATH=bin/${OUTPUT_NAME}" >> $GITHUB_ENV
|
||||
echo "BINARY_NAME=${OUTPUT_NAME}" >> $GITHUB_ENV
|
||||
|
||||
- name: Create release assets directory
|
||||
- name: Create or Update Release
|
||||
run: |
|
||||
mkdir -p release-assets
|
||||
cp ${{ env.BINARY_PATH }} release-assets/
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
REPO="${{ gitea.repository }}"
|
||||
SERVER="${{ gitea.server_url }}"
|
||||
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||
|
||||
# Try to create release (ignore error if already exists)
|
||||
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"tag_name": "'${VERSION}'",
|
||||
"target_commitish": "main",
|
||||
"name": "Release '${VERSION}'",
|
||||
"body": "# SafelineAPI '${VERSION}'\n\n## Available Downloads\n\n### Linux\n- **amd64**: safelineApi-linux-amd64\n- **ARM64**: safelineApi-linux-arm64\n- **ARMv7**: safelineApi-linux-armv7\n- **386**: safelineApi-linux-386\n- **PowerPC 64LE**: safelineApi-linux-ppc64le\n\n### Windows\n- **amd64**: safelineApi-windows-amd64.exe\n- **386**: safelineApi-windows-386.exe",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}' || true
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.name }}
|
||||
path: release-assets/${{ env.BINARY_NAME }}
|
||||
retention-days: 1
|
||||
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: release-artifacts
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Flatten artifacts
|
||||
- name: Upload Binary Asset
|
||||
run: |
|
||||
mkdir -p final-release
|
||||
find release-artifacts -type f -exec mv {} final-release/ \;
|
||||
ls -la final-release/
|
||||
|
||||
- name: Create Release
|
||||
uses: gitea-github-actions/actions/gitea-release@main
|
||||
with:
|
||||
files: final-release/*
|
||||
draft: false
|
||||
prerelease: false
|
||||
title: Release ${{ steps.version.outputs.VERSION }}
|
||||
body: |
|
||||
# SafelineAPI ${{ steps.version.outputs.VERSION }}
|
||||
|
||||
## Available Downloads
|
||||
|
||||
### Linux
|
||||
- **amd64**: safelineApi-linux-amd64
|
||||
- **ARM64**: safelineApi-linux-arm64
|
||||
- **ARMv7**: safelineApi-linux-armv7
|
||||
- **386**: safelineApi-linux-386
|
||||
- **PowerPC 64LE**: safelineApi-linux-ppc64le
|
||||
|
||||
### Windows
|
||||
- **amd64**: safelineApi-windows-amd64.exe
|
||||
- **386**: safelineApi-windows-386.exe
|
||||
|
||||
Built at: ${{ github.event.head_commit.timestamp }}
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_SERVER: ${{ gitea.server_url }}
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
REPO="${{ gitea.repository }}"
|
||||
SERVER="${{ gitea.server_url }}"
|
||||
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||
BINARY="${{ env.BINARY_NAME }}"
|
||||
|
||||
# Get release ID
|
||||
RELEASE_ID=$(curl -s "${SERVER}/api/v1/repos/${REPO}/releases/tags/${VERSION}" \
|
||||
-H "Authorization: token ${TOKEN}" | grep '"id"' | head -1 | grep -o '[0-9]*')
|
||||
|
||||
# Upload the binary
|
||||
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-F "attachment=@bin/${BINARY}" || true
|
||||
|
||||
Reference in New Issue
Block a user