This commit is contained in:
parent
cf11ff6a65
commit
06c01340b4
1 changed files with 30 additions and 12 deletions
|
|
@ -1,9 +1,16 @@
|
||||||
name: release
|
name: release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
push:
|
||||||
types: [published]
|
branches:
|
||||||
workflow_dispatch: # allows manual runs from ui
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Tag to release (empty = build only)'
|
||||||
|
required: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -35,18 +42,29 @@ jobs:
|
||||||
zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseFast
|
zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseFast
|
||||||
mv zig-out/bin/sandbox.exe lofivor-windows-x86_64.exe
|
mv zig-out/bin/sandbox.exe lofivor-windows-x86_64.exe
|
||||||
|
|
||||||
- name: Upload to release
|
- name: Create release and upload
|
||||||
|
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.tag != ''
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
RELEASE_ID="${{ github.event.release.id }}"
|
TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
||||||
API_URL="${{ github.api_url }}/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets"
|
API_BASE="${{ github.server_url }}/api/v1"
|
||||||
|
REPO="${{ github.repository }}"
|
||||||
|
|
||||||
|
# create release
|
||||||
|
RELEASE_ID=$(curl -sf -X POST \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\"}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
|
||||||
|
|
||||||
|
echo "Created release ${RELEASE_ID}"
|
||||||
|
|
||||||
|
# upload assets
|
||||||
for file in lofivor-linux-x86_64 lofivor-windows-x86_64.exe; do
|
for file in lofivor-linux-x86_64 lofivor-windows-x86_64.exe; do
|
||||||
echo "Uploading $file..."
|
echo "Uploading $file..."
|
||||||
curl -X POST \
|
curl -sf -X POST \
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-F "attachment=@${file}" \
|
||||||
--data-binary @"$file" \
|
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${file}"
|
||||||
"${API_URL}?name=${file}"
|
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue