91 lines
3.1 KiB
YAML
91 lines
3.1 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Install Wine (for Windows cross-compile)
|
|
run: |
|
|
sudo dpkg --add-architecture i386
|
|
sudo apt-get update
|
|
sudo apt-get install -y wine64 wine32 xvfb
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
npm install
|
|
npm run install:frontend
|
|
|
|
- name: Read version from package.json
|
|
id: version
|
|
run: |
|
|
VERSION=$(node -p "require('./Frontend/Electron/package.json').version")
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build Electron app
|
|
run: |
|
|
cd Frontend/Electron
|
|
npm run build
|
|
npx electron-builder --linux
|
|
xvfb-run npx electron-builder --win
|
|
env:
|
|
GH_TOKEN: ${{ secrets.CI_TOKEN }}
|
|
WINEDEBUG: "-all"
|
|
|
|
- name: Delete existing latest release
|
|
run: |
|
|
RELEASE_ID=$(curl -s -H "Authorization: token $TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases/tags/latest" | jq -r '.id')
|
|
if [ "$RELEASE_ID" != "null" ] && [ -n "$RELEASE_ID" ]; then
|
|
curl -X DELETE -H "Authorization: token $TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID"
|
|
# Also delete the tag so it can be recreated
|
|
curl -X DELETE -H "Authorization: token $TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/tags/latest"
|
|
fi
|
|
env:
|
|
GITEA_URL: ${{ secrets.CI_URL }}
|
|
REPO: ${{ gitea.repository }}
|
|
TOKEN: ${{ secrets.CI_TOKEN }}
|
|
|
|
- name: Create release and upload artifacts
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
|
|
# Create new release with latest tag
|
|
RELEASE_ID=$(curl -s -X POST -H "Authorization: token $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"latest\",\"name\":\"v${VERSION}\",\"body\":\"Auto-release v${VERSION} from CI\"}" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases" | jq -r '.id')
|
|
|
|
echo "Created release ID: $RELEASE_ID"
|
|
|
|
# Upload each artifact
|
|
for file in Frontend/Electron/dist/latest*.yml \
|
|
Frontend/Electron/dist/*.exe \
|
|
Frontend/Electron/dist/*.exe.blockmap \
|
|
Frontend/Electron/dist/*.AppImage; do
|
|
[ -f "$file" ] || continue
|
|
FILENAME=$(basename "$file")
|
|
ENCODED_NAME=$(echo -n "$FILENAME" | jq -sRr @uri)
|
|
echo "Uploading: $FILENAME"
|
|
curl -X POST -H "Authorization: token $TOKEN" \
|
|
-F "attachment=@$file" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$ENCODED_NAME"
|
|
done
|
|
env:
|
|
GITEA_URL: ${{ secrets.CI_URL }}
|
|
REPO: ${{ gitea.repository }}
|
|
TOKEN: ${{ secrets.CI_TOKEN }}
|