114 lines
3.2 KiB
YAML
114 lines
3.2 KiB
YAML
name: test-build-release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install test deps
|
|
run: |
|
|
python -m venv .venv-ci
|
|
. .venv-ci/bin/activate
|
|
pip install --upgrade pip
|
|
pip install -r requirements.txt pytest
|
|
|
|
- name: Run tests
|
|
run: |
|
|
. .venv-ci/bin/activate
|
|
pytest -q
|
|
|
|
build-linux:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install OS deps
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y python3-venv libfuse2 wget jq
|
|
|
|
- name: Build Linux binary
|
|
run: bash build/build_linux.sh
|
|
|
|
- name: Install appimagetool
|
|
run: |
|
|
wget -O /tmp/appimagetool.AppImage \
|
|
https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
|
|
chmod +x /tmp/appimagetool.AppImage
|
|
sudo mv /tmp/appimagetool.AppImage /usr/local/bin/appimagetool
|
|
|
|
- name: Build AppImage
|
|
run: bash build/build_appimage.sh
|
|
|
|
- name: Upload binary artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: TrulyMEM-linux-${{ github.sha }}
|
|
path: |
|
|
dist/TrulyMEM
|
|
dist/TrulyMEM.desktop
|
|
dist/TrulyMEM.AppImage
|
|
if-no-files-found: error
|
|
retention-days: 30
|
|
|
|
- name: Create Gitea release
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_RELEASE_TOKEN }}
|
|
TAG_NAME: ${{ github.ref_name }}
|
|
REPO: ${{ github.repository }}
|
|
SERVER_URL: ${{ github.server_url }}
|
|
run: |
|
|
test -n "$GITEA_TOKEN"
|
|
|
|
release_payload=$(jq -n \
|
|
--arg tag "$TAG_NAME" \
|
|
'{tag_name:$tag, name:$tag, draft:false, prerelease:false}')
|
|
|
|
release_response=$(curl -fsSL \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-X POST \
|
|
"$SERVER_URL/api/v1/repos/$REPO/releases" \
|
|
-d "$release_payload" \
|
|
|| true)
|
|
|
|
release_id=$(printf '%s' "$release_response" | jq -r '.id // empty')
|
|
|
|
if [ -z "$release_id" ]; then
|
|
release_id=$(curl -fsSL \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
"$SERVER_URL/api/v1/repos/$REPO/releases/tags/$TAG_NAME" | jq -r '.id')
|
|
fi
|
|
|
|
for file in dist/TrulyMEM dist/TrulyMEM.desktop dist/TrulyMEM.AppImage; do
|
|
name=$(basename "$file")
|
|
curl -fsSL \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary @"$file" \
|
|
"$SERVER_URL/api/v1/repos/$REPO/releases/$release_id/assets?name=$name"
|
|
done
|