Compare commits
2 Commits
6578e93a16
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 30f4ebbd6d | |||
| 17a0346aa8 |
@@ -6,7 +6,7 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
@@ -65,68 +65,41 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
go build -ldflags "-X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME}" \
|
go build -ldflags "-X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME}" \
|
||||||
-o bin/${OUTPUT_NAME} ./cmd/safelineApi
|
-o bin/${OUTPUT_NAME} ./cmd/safelineApi
|
||||||
echo "BINARY_PATH=bin/${OUTPUT_NAME}" >> $GITHUB_ENV
|
|
||||||
echo "BINARY_NAME=${OUTPUT_NAME}" >> $GITHUB_ENV
|
echo "BINARY_NAME=${OUTPUT_NAME}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create release assets directory
|
- name: Create or Update Release
|
||||||
run: |
|
run: |
|
||||||
mkdir -p release-assets
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
cp ${{ env.BINARY_PATH }} release-assets/
|
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
|
- name: Upload Binary Asset
|
||||||
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
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p final-release
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
find release-artifacts -type f -exec mv {} final-release/ \;
|
REPO="${{ gitea.repository }}"
|
||||||
ls -la final-release/
|
SERVER="${{ gitea.server_url }}"
|
||||||
|
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||||
- name: Create Release
|
BINARY="${{ env.BINARY_NAME }}"
|
||||||
uses: gitea-github-actions/actions/gitea-release@main
|
|
||||||
with:
|
# Get release ID
|
||||||
files: final-release/*
|
RELEASE_ID=$(curl -s "${SERVER}/api/v1/repos/${REPO}/releases/tags/${VERSION}" \
|
||||||
draft: false
|
-H "Authorization: token ${TOKEN}" | grep '"id"' | head -1 | grep -o '[0-9]*')
|
||||||
prerelease: false
|
|
||||||
title: Release ${{ steps.version.outputs.VERSION }}
|
# Upload the binary
|
||||||
body: |
|
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
||||||
# SafelineAPI ${{ steps.version.outputs.VERSION }}
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-F "attachment=@bin/${BINARY}" || true
|
||||||
## 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 }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user