Gitea build debugging
Some checks failed
Build Release Binaries / build-and-release (push) Failing after 5m17s
Some checks failed
Build Release Binaries / build-and-release (push) Failing after 5m17s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Build release binaries
|
||||
name: Build Release Binaries
|
||||
|
||||
on:
|
||||
release:
|
||||
@@ -12,34 +12,11 @@ permissions:
|
||||
|
||||
env:
|
||||
BINARY_NAME: streamed-tui
|
||||
API_BASE: https://git.salastil.com/api/v1
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
archive: tar.gz
|
||||
extension: ""
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
archive: tar.gz
|
||||
extension: ""
|
||||
- goos: windows
|
||||
goarch: amd64
|
||||
archive: zip
|
||||
extension: ".exe"
|
||||
- goos: darwin
|
||||
goarch: amd64
|
||||
archive: tar.gz
|
||||
extension: ""
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
archive: tar.gz
|
||||
extension: ""
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -51,71 +28,100 @@ jobs:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- name: Build ${{ matrix.goos }} ${{ matrix.goarch }} binary
|
||||
env:
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
CGO_ENABLED: 0
|
||||
EXTENSION: ${{ matrix.extension }}
|
||||
- name: Build all platform binaries
|
||||
run: |
|
||||
mkdir -p dist
|
||||
OUTPUT="${BINARY_NAME}${EXTENSION}"
|
||||
go build -o "dist/${OUTPUT}" .
|
||||
|
||||
- name: Package artifact
|
||||
env:
|
||||
EXTENSION: ${{ matrix.extension }}
|
||||
build() {
|
||||
GOOS=$1 GOARCH=$2 EXT=$3
|
||||
OUT="${BINARY_NAME}${EXT}"
|
||||
echo "Building $1 $2 => $OUT"
|
||||
env GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -o "dist/${OUT}" .
|
||||
}
|
||||
|
||||
build linux amd64 ""
|
||||
build linux arm64 ""
|
||||
build windows amd64 ".exe"
|
||||
build darwin amd64 ""
|
||||
build darwin arm64 ""
|
||||
|
||||
- name: Package binaries
|
||||
run: |
|
||||
cd dist
|
||||
OUTPUT="${BINARY_NAME}${EXTENSION}"
|
||||
ARCHIVE="${BINARY_NAME}_${{ matrix.goos }}_${{ matrix.goarch }}"
|
||||
if [ "${{ matrix.archive }}" = "zip" ]; then
|
||||
zip "${ARCHIVE}.zip" "${OUTPUT}"
|
||||
else
|
||||
tar -czf "${ARCHIVE}.tar.gz" "${OUTPUT}"
|
||||
|
||||
pack() {
|
||||
NAME="$1"
|
||||
EXT="$2"
|
||||
|
||||
if [[ "$EXT" == "zip" ]]; then
|
||||
zip "${NAME}.zip" "${BINARY_NAME}${3}"
|
||||
else
|
||||
tar -czf "${NAME}.tar.gz" "${BINARY_NAME}${3}"
|
||||
fi
|
||||
}
|
||||
|
||||
pack streamed-tui_linux_amd64 tar.gz ""
|
||||
pack streamed-tui_linux_arm64 tar.gz ""
|
||||
pack streamed-tui_windows_amd64 zip ".exe"
|
||||
pack streamed-tui_darwin_amd64 tar.gz ""
|
||||
pack streamed-tui_darwin_arm64 tar.gz ""
|
||||
|
||||
- name: Create release in Gitea
|
||||
id: create_release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
REPO: ${{ github.repository }}
|
||||
API_BASE: ${{ env.API_BASE }}
|
||||
run: |
|
||||
if [ -z "$GITEA_TOKEN" ]; then
|
||||
echo "ERROR: Missing CI_TOKEN secret"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: https://gitea.com/actions/upload-artifact@v1
|
||||
with:
|
||||
name: ${{ env.BINARY_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }}
|
||||
path: dist/${{ env.BINARY_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }}.*
|
||||
if-no-files-found: error
|
||||
echo "Creating release for tag: $TAG"
|
||||
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: https://gitea.com/actions/download-artifact@v1
|
||||
with:
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"tag_name\": \"${TAG}\",
|
||||
\"name\": \"Release ${TAG}\",
|
||||
\"body\": \"Automated release for ${TAG}\",
|
||||
\"draft\": false,
|
||||
\"prerelease\": false
|
||||
}" \
|
||||
"${API_BASE}/repos/${REPO}/releases")
|
||||
|
||||
- name: Publish release assets on GitHub
|
||||
if: startsWith(github.server_url, 'https://github.com')
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: dist/*
|
||||
echo "RESPONSE=$RESPONSE"
|
||||
|
||||
- name: Publish release assets on Gitea
|
||||
if: startsWith(github.server_url, 'https://github.com') == 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 "ERROR: Failed to extract release ID"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload release assets
|
||||
env:
|
||||
API_URL: ${{ github.api_url }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
RELEASE_ID: ${{ github.event.release.id }}
|
||||
TOKEN: ${{ secrets.CI_TOKEN || secrets.GITHUB_TOKEN || github.token }}
|
||||
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||
RELEASE_ID: ${{ steps.create_release.outputs.release_id }}
|
||||
API_BASE: ${{ env.API_BASE }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
for file in dist/*; do
|
||||
name=$(basename "${file}")
|
||||
curl -sfSL -X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
echo "Uploading assets..."
|
||||
cd dist
|
||||
|
||||
for file in *; do
|
||||
echo "Uploading $file..."
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"${file}" \
|
||||
"${API_URL}/repos/${REPOSITORY}/releases/${RELEASE_ID}/assets?name=${name}"
|
||||
--data-binary @"$file" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
|
||||
done
|
||||
shell: bash
|
||||
|
||||
echo "All assets uploaded."
|
||||
|
||||
Reference in New Issue
Block a user