58 lines
1.7 KiB
YAML
58 lines
1.7 KiB
YAML
on:
|
|
push:
|
|
tags:
|
|
- 'v*.*.*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: https://code.forgejo.org/actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install -r requirements.txt
|
|
pip install pyinstaller
|
|
|
|
- name: Build with PyInstaller
|
|
run: |
|
|
pyinstaller --onefile --console --name TinyWeb app.py
|
|
|
|
- name: Prepare artifact
|
|
run: |
|
|
cp dist/TinyWeb TinyWeb-linux-x64
|
|
chmod +x TinyWeb-linux-x64
|
|
ls -la TinyWeb-linux-x64
|
|
|
|
- name: Get Release ID
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
id: release
|
|
run: |
|
|
TAG="${{ github.ref_name }}"
|
|
REPO="${{ github.repository }}"
|
|
TOKEN="${{ secrets.FORGEJO_TOKEN }}"
|
|
RELEASE_JSON=$(curl -s "https://git.derickphan.com/api/v1/repos/$REPO/releases/tags/$TAG" \
|
|
-H "Authorization: token $TOKEN")
|
|
echo "$RELEASE_JSON"
|
|
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
|
|
echo "release_id=$RELEASE_ID" >> $FORGEJO_OUTPUT
|
|
|
|
- name: Upload to Release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
FILE=TinyWeb-linux-x64
|
|
RELEASE_ID="${{ steps.release.outputs.release_id }}"
|
|
REPO="${{ github.repository }}"
|
|
TOKEN="${{ secrets.FORGEJO_TOKEN }}"
|
|
curl -X POST "https://git.derickphan.com/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \
|
|
-H "Authorization: token $TOKEN" \
|
|
-F "attachment=@$FILE"
|
|
|