feat: implement cross-platform auto-update functionality via GitHub r… #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release DBoplia | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| bump-version: | |
| name: Bump Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_tag: ${{ steps.get_tag.outputs.new_tag }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get next tag | |
| id: get_tag | |
| run: | | |
| git fetch --tags origin || true | |
| # Get the absolute highest semantic version tag across all history | |
| LATEST_TAG=$(git tag -l "v[0-9]*" | sort -V | tail -n 1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| LATEST_TAG="v0.0.0" | |
| fi | |
| if [[ $LATEST_TAG =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
| MAJOR="${BASH_REMATCH[1]}" | |
| MINOR="${BASH_REMATCH[2]}" | |
| PATCH="${BASH_REMATCH[3]}" | |
| else | |
| MAJOR=0 | |
| MINOR=0 | |
| PATCH=0 | |
| fi | |
| while true; do | |
| PATCH=$((PATCH + 1)) | |
| if [ "$PATCH" -ge 10 ]; then | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| fi | |
| if [ "$MINOR" -ge 10 ]; then | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| fi | |
| NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}" | |
| # Check for conflict explicitly just in case | |
| if ! git rev-parse "refs/tags/$NEW_TAG" >/dev/null 2>&1; then | |
| break | |
| fi | |
| done | |
| echo "NEW_TAG resolved to: $NEW_TAG" | |
| echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT | |
| - name: Update app.go version | |
| run: | | |
| sed -i 's/const AppVersion = "[^"]*"/const AppVersion = "'"${{ steps.get_tag.outputs.new_tag }}"'"/' app.go | |
| - name: Commit and push | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add app.go | |
| git commit -m "chore: bump version to ${{ steps.get_tag.outputs.new_tag }} [skip ci]" || true | |
| git tag ${{ steps.get_tag.outputs.new_tag }} | |
| git push origin main --tags | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.get_tag.outputs.new_tag }} | |
| name: Release ${{ steps.get_tag.outputs.new_tag }} | |
| generate_release_notes: true | |
| build: | |
| name: Build DBoplia | |
| needs: bump-version | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-22.04, macos-latest, windows-latest] | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.bump-version.outputs.new_tag }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26.1' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev curl ca-certificates | |
| sudo install -d /usr/share/postgresql-common/pgdg | |
| sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc | |
| sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
| sudo apt-get update | |
| sudo apt-get install -y postgresql-client-16 | |
| - name: Prepare Postgres Tools (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| mkdir -p migrator/embedded/bin | |
| cp /usr/lib/postgresql/16/bin/pg_dump migrator/embedded/bin/pg_dump_linux_amd64 || cp /usr/bin/pg_dump migrator/embedded/bin/pg_dump_linux_amd64 | |
| cp /usr/lib/postgresql/16/bin/psql migrator/embedded/bin/psql_linux_amd64 || cp /usr/bin/psql migrator/embedded/bin/psql_linux_amd64 | |
| - name: Prepare Postgres Tools (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| mkdir -p migrator/embedded/bin | |
| brew install postgresql@16 || true | |
| brew link postgresql@16 --force || true | |
| cp $(which pg_dump) migrator/embedded/bin/pg_dump_darwin_amd64 | |
| cp $(which psql) migrator/embedded/bin/psql_darwin_amd64 | |
| cp $(which pg_dump) migrator/embedded/bin/pg_dump_darwin_arm64 | |
| cp $(which psql) migrator/embedded/bin/psql_darwin_arm64 | |
| - name: Prepare Postgres Tools (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| New-Item -ItemType Directory -Force -Path migrator/embedded/bin | |
| choco install postgresql16 --force --params '/NoServer' || echo "Choco install failed, trying default" | |
| $pgDump = (Get-ChildItem -Path "C:\Program Files\PostgreSQL" -Filter "pg_dump.exe" -Recurse) | Where-Object { $_.FullName -match "16" } | Select-Object -First 1 | |
| $psql = (Get-ChildItem -Path "C:\Program Files\PostgreSQL" -Filter "psql.exe" -Recurse) | Where-Object { $_.FullName -match "16" } | Select-Object -First 1 | |
| if (-not $pgDump) { $pgDump = (Get-ChildItem -Path "C:\Program Files\PostgreSQL" -Filter "pg_dump.exe" -Recurse) | Select-Object -First 1 } | |
| if (-not $psql) { $psql = (Get-ChildItem -Path "C:\Program Files\PostgreSQL" -Filter "psql.exe" -Recurse) | Select-Object -First 1 } | |
| Copy-Item $pgDump.FullName -Destination migrator/embedded/bin/pg_dump_windows_amd64.exe | |
| Copy-Item $psql.FullName -Destination migrator/embedded/bin/psql_windows_amd64.exe | |
| - name: Install Wails CLI | |
| run: go install github.com/wailsapp/wails/v2/cmd/wails@latest | |
| - name: Build DBoplia (Windows) | |
| if: runner.os == 'Windows' | |
| run: wails build -platform windows/amd64 | |
| - name: Build DBoplia (macOS) | |
| if: runner.os == 'macOS' | |
| run: wails build -platform darwin/universal | |
| - name: Build DBoplia (Linux) | |
| if: runner.os == 'Linux' | |
| run: wails build -platform linux/amd64 | |
| - name: Package binaries | |
| shell: bash | |
| run: | | |
| cd build/bin | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| mv DBoplia.exe DBoplia-windows.exe | |
| elif [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then | |
| tar -czvf DBoplia-linux.tar.gz DBoplia | |
| elif [ "${{ matrix.os }}" = "macos-latest" ]; then | |
| tar -czvf DBoplia-macos.tar.gz DBoplia.app/ | |
| fi | |
| - name: Upload Release Assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.bump-version.outputs.new_tag }} | |
| files: build/bin/DBoplia-* |