Tons of Stuff
This commit is contained in:
49
.gitea/workflows/README.md
Normal file
49
.gitea/workflows/README.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Gitea Actions - Release Workflow
|
||||
|
||||
This workflow automatically builds and releases rmtPocketWatcher for Windows and Linux when you push a version tag.
|
||||
|
||||
## How to Trigger a Release
|
||||
|
||||
1. Update version in `electron-app/package.json`:
|
||||
```bash
|
||||
cd electron-app
|
||||
npm version patch # or minor, or major
|
||||
```
|
||||
|
||||
2. Push the tag to Gitea:
|
||||
```bash
|
||||
git push origin main
|
||||
git push origin --tags
|
||||
```
|
||||
|
||||
3. The workflow will automatically:
|
||||
- Build Windows installer (.exe)
|
||||
- Build Linux AppImage and .deb package
|
||||
- Create a GitHub/Gitea release
|
||||
- Upload all binaries to the release
|
||||
|
||||
## Requirements
|
||||
|
||||
- Gitea Actions must be enabled on your repository
|
||||
- Runners must be configured for `windows-latest` and `ubuntu-latest`
|
||||
- Repository must have write permissions for releases
|
||||
|
||||
## Manual Build
|
||||
|
||||
To build locally without releasing:
|
||||
|
||||
```bash
|
||||
cd electron-app
|
||||
npm run electron:build -- --win # Windows
|
||||
npm run electron:build -- --linux # Linux
|
||||
```
|
||||
|
||||
Outputs will be in `electron-app/release/`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If the workflow fails:
|
||||
- Check that Node.js 20 is available on runners
|
||||
- Verify all dependencies install correctly
|
||||
- Check Gitea Actions logs for specific errors
|
||||
- Ensure GITHUB_TOKEN has proper permissions
|
||||
86
.gitea/workflows/deploy.yml
Normal file
86
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,86 @@
|
||||
name: Deploy Backend to Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'backend/**'
|
||||
- 'docker-compose.yml'
|
||||
- '.gitea/workflows/deploy.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build backend image
|
||||
working-directory: backend
|
||||
run: docker build -t rmtpocketwatcher-backend:latest .
|
||||
|
||||
- name: Save image to tar
|
||||
run: docker save rmtpocketwatcher-backend:latest -o backend-image.tar
|
||||
|
||||
- name: Deploy via SSH to Docker host
|
||||
env:
|
||||
DOCKER_HOST: ${{ secrets.DOCKER_HOST }}
|
||||
DOCKER_SSH_KEY: ${{ secrets.DOCKER_SSH_KEY }}
|
||||
DOCKER_USER: ${{ secrets.DOCKER_USER }}
|
||||
run: |
|
||||
# Setup SSH
|
||||
mkdir -p ~/.ssh
|
||||
echo "$DOCKER_SSH_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
# Copy image to remote host
|
||||
scp -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \
|
||||
backend-image.tar ${DOCKER_USER}@${DOCKER_HOST}:/tmp/
|
||||
|
||||
# Copy docker-compose to remote host
|
||||
scp -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \
|
||||
docker-compose.yml ${DOCKER_USER}@${DOCKER_HOST}:/opt/rmtpocketwatcher/
|
||||
|
||||
# Load image and restart services
|
||||
ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \
|
||||
${DOCKER_USER}@${DOCKER_HOST} << 'EOF'
|
||||
cd /opt/rmtpocketwatcher
|
||||
docker load -i /tmp/backend-image.tar
|
||||
docker-compose down backend
|
||||
docker-compose up -d backend
|
||||
rm /tmp/backend-image.tar
|
||||
EOF
|
||||
|
||||
deploy-portainer:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy via Portainer Webhook
|
||||
env:
|
||||
PORTAINER_WEBHOOK_URL: ${{ secrets.PORTAINER_WEBHOOK_URL }}
|
||||
run: |
|
||||
curl -X POST "$PORTAINER_WEBHOOK_URL"
|
||||
|
||||
- name: Deploy via Portainer API
|
||||
env:
|
||||
PORTAINER_URL: ${{ secrets.PORTAINER_URL }}
|
||||
PORTAINER_API_KEY: ${{ secrets.PORTAINER_API_KEY }}
|
||||
PORTAINER_STACK_ID: ${{ secrets.PORTAINER_STACK_ID }}
|
||||
run: |
|
||||
# Pull latest from git and redeploy stack
|
||||
curl -X PUT \
|
||||
"${PORTAINER_URL}/api/stacks/${PORTAINER_STACK_ID}/git/redeploy" \
|
||||
-H "X-API-Key: ${PORTAINER_API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"pullImage": true,
|
||||
"prune": true
|
||||
}'
|
||||
96
.gitea/workflows/release.yml
Normal file
96
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,96 @@
|
||||
name: Build and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install electron-app dependencies
|
||||
working-directory: electron-app
|
||||
run: npm ci
|
||||
|
||||
- name: Build and package for Windows
|
||||
working-directory: electron-app
|
||||
run: npm run electron:build -- --win
|
||||
|
||||
- name: Upload Windows artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-build
|
||||
path: electron-app/release/*.exe
|
||||
retention-days: 7
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install electron-app dependencies
|
||||
working-directory: electron-app
|
||||
run: npm ci
|
||||
|
||||
- name: Build and package for Linux
|
||||
working-directory: electron-app
|
||||
run: npm run electron:build -- --linux
|
||||
|
||||
- name: Upload Linux AppImage
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-appimage
|
||||
path: electron-app/release/*.AppImage
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload Linux deb
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-deb
|
||||
path: electron-app/release/*.deb
|
||||
retention-days: 7
|
||||
|
||||
create-release:
|
||||
needs: [build-windows, build-linux]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./artifacts
|
||||
|
||||
- name: Display structure of downloaded files
|
||||
run: ls -R ./artifacts
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
artifacts/windows-build/*.exe
|
||||
artifacts/linux-appimage/*.AppImage
|
||||
artifacts/linux-deb/*.deb
|
||||
draft: false
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in New Issue
Block a user