chore: configure fork publish target and automated upstream sync workflow

This commit is contained in:
Murilo Scolari 2026-11-01 04:49:18 -03:00
parent 64ac69a37b
commit 837b482ac8
2 changed files with 259 additions and 1 deletions

258
.github/workflows/fork-sync-release.yml vendored Normal file
View file

@ -0,0 +1,258 @@
name: Fork Sync & Release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
publish_release:
description: "Compilar e publicar release da versão atual mesmo sem nova versão upstream"
required: false
default: false
type: boolean
permissions:
contents: write
issues: write
jobs:
sync:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.decide.outputs.should_release }}
version: ${{ steps.decide.outputs.version }}
steps:
- name: Check out fork main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22.21.0
cache: "yarn"
- name: Sync with hydralauncher/hydra main
id: merge_upstream
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git remote get-url upstream >/dev/null 2>&1; then
git remote set-url upstream https://github.com/hydralauncher/hydra.git
else
git remote add upstream https://github.com/hydralauncher/hydra.git
fi
git fetch upstream main --tags
UPSTREAM_SHA=$(git rev-parse --short upstream/main)
if git merge-base --is-ancestor upstream/main HEAD; then
echo "Fork main já contém upstream/main (${UPSTREAM_SHA})."
echo "upstream_merged=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Mesclando upstream/main (${UPSTREAM_SHA}) em main..."
if ! git merge --no-edit upstream/main; then
git merge --abort || true
TITLE="[Auto-Sync] Conflito ao sincronizar com hydralauncher/hydra (${UPSTREAM_SHA})"
EXISTING=$(gh issue list --repo "${{ github.repository }}" --state open --search "[Auto-Sync] Conflito ao sincronizar" --json number --jq '.[0].number // empty')
BODY="O workflow automático encontrou conflito de merge ao tentar sincronizar \`upstream/main\` (\`${UPSTREAM_SHA}\`) no branch \`main\`.\n\nNenhuma alteração quebrada foi enviada para \`main\`. Para resolver localmente:\n\`\`\`bash\ngit fetch upstream main\ngit checkout main\ngit merge upstream/main\n# resolva os conflitos, rode yarn typecheck && yarn test e dê git push origin main\n\`\`\`"
if [ -n "${EXISTING}" ]; then
gh issue comment "${EXISTING}" --repo "${{ github.repository }}" --body "${BODY}"
else
gh issue create --repo "${{ github.repository }}" --title "${TITLE}" --body "${BODY}"
fi
exit 1
fi
if ! grep -q "owner: muriloscolari" electron-builder.yml; then
echo "ERRO: publish.owner em electron-builder.yml não aponta para muriloscolari!"
exit 1
fi
yarn --frozen-lockfile --ignore-scripts
if ! (yarn typecheck && yarn test); then
PREVIEW_BRANCH="sync/upstream-${UPSTREAM_SHA}"
git push -f origin "HEAD:refs/heads/${PREVIEW_BRANCH}"
TITLE="[Auto-Sync] Falha nos testes após merge com hydralauncher/hydra (${UPSTREAM_SHA})"
EXISTING=$(gh issue list --repo "${{ github.repository }}" --state open --search "[Auto-Sync] Falha nos testes" --json number --jq '.[0].number // empty')
BODY="O merge com \`upstream/main\` (\`${UPSTREAM_SHA}\`) não teve conflitos de git, mas falhou em \`yarn typecheck && yarn test\`.\n\nO branch \`main\` foi preservado intacto e o resultado foi salvo em \`${PREVIEW_BRANCH}\` para inspeção."
if [ -n "${EXISTING}" ]; then
gh issue comment "${EXISTING}" --repo "${{ github.repository }}" --body "${BODY}"
else
gh issue create --repo "${{ github.repository }}" --title "${TITLE}" --body "${BODY}"
fi
exit 1
fi
git push origin main
echo "upstream_merged=true" >> "$GITHUB_OUTPUT"
- name: Determine whether a GitHub Release should be built
id: decide
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORCE_RELEASE: ${{ inputs.publish_release }}
run: |
set -euo pipefail
VERSION=$(node -p "require('./package.json').version")
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
if [ "${FORCE_RELEASE}" = "true" ]; then
echo "should_release=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if gh release view "v${VERSION}" --repo "${{ github.repository }}" >/dev/null 2>&1; then
echo "Release v${VERSION} já existe em ${{ github.repository }}."
echo "should_release=false" >> "$GITHUB_OUTPUT"
else
echo "Nova versão detectada (v${VERSION}) sem release publicada. Iniciando build!"
echo "should_release=true" >> "$GITHUB_OUTPUT"
fi
build:
needs: sync
if: needs.sync.outputs.should_release == 'true'
strategy:
fail-fast: true
matrix:
os: [windows-2022, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out fork main
uses: actions/checkout@v4
with:
ref: main
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22.21.0
cache: "yarn"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Prepare native caches
id: native-cache
shell: pwsh
run: |
$cacheDir = Join-Path $env:RUNNER_TEMP "hydra-vcpkg-archives"
New-Item -ItemType Directory -Force -Path $cacheDir | Out-Null
"VCPKG_DEFAULT_BINARY_CACHE=$cacheDir" >> $env:GITHUB_ENV
$arch = $env:RUNNER_ARCH.ToLowerInvariant()
$platform = if ($env:RUNNER_OS -eq "Windows") { "windows-static" } else { "linux" }
$image = "$env:ImageOS-$env:ImageVersion"
"image=$image" >> $env:GITHUB_OUTPUT
"prefix=v1-vcpkg-$env:RUNNER_OS-$image-$arch-$arch-$platform" >> $env:GITHUB_OUTPUT
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
with:
workspaces: native/hydra-native -> target
shared-key: native-${{ runner.os }}-${{ runner.arch }}-${{ steps.native-cache.outputs.image }}
cache-bin: false
- name: Check prebuilt torrent bridge
id: torrent-bridge
run: node scripts/torrent-bridge-prebuilt.cjs check
- name: Restore vcpkg binary packages
if: steps.torrent-bridge.outputs.current != 'true'
id: vcpkg-cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ steps.native-cache.outputs.prefix }}-${{ hashFiles('native/torrent-bridge/**/vcpkg*.json', 'native/torrent-bridge/**/triplets/**') }}
restore-keys: |
${{ steps.native-cache.outputs.prefix }}-
- name: Install Linux native build prerequisites
if: runner.os == 'Linux'
run: |
rustup target add x86_64-pc-windows-gnu
sudo apt-get update && sudo apt-get install -y build-essential cmake ninja-build pkg-config curl zip unzip tar autoconf automake libtool gcc-mingw-w64-x86-64
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Save vcpkg binary packages
if: steps.torrent-bridge.outputs.current != 'true' && steps.vcpkg-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ steps.vcpkg-cache.outputs.cache-primary-key }}
- name: Build Linux
if: matrix.os == 'ubuntu-latest'
run: yarn build:linux
env:
MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_API_URL || 'https://hydra-api-us-east-1.losbroxas.org' }}
MAIN_VITE_AUTH_URL: ${{ vars.MAIN_VITE_AUTH_URL || 'https://auth.hydra.losbroxas.org' }}
MAIN_VITE_CHECKOUT_URL: ${{ vars.MAIN_VITE_CHECKOUT_URL || 'https://checkout.hydralauncher.gg' }}
MAIN_VITE_NIMBUS_API_URL: ${{ vars.MAIN_VITE_NIMBUS_API_URL || '' }}
RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.EXTERNAL_RESOURCES_URL || 'https://assets.hydralauncher.gg' }}
MAIN_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.EXTERNAL_RESOURCES_URL || 'https://assets.hydralauncher.gg' }}
MAIN_VITE_LAUNCHER_SUBDOMAIN: ${{ vars.MAIN_VITE_LAUNCHER_SUBDOMAIN || '' }}
- name: Build Windows
if: matrix.os == 'windows-2022'
run: yarn build:win
env:
MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_API_URL || 'https://hydra-api-us-east-1.losbroxas.org' }}
MAIN_VITE_AUTH_URL: ${{ vars.MAIN_VITE_AUTH_URL || 'https://auth.hydra.losbroxas.org' }}
MAIN_VITE_CHECKOUT_URL: ${{ vars.MAIN_VITE_CHECKOUT_URL || 'https://checkout.hydralauncher.gg' }}
MAIN_VITE_NIMBUS_API_URL: ${{ vars.MAIN_VITE_NIMBUS_API_URL || '' }}
RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.EXTERNAL_RESOURCES_URL || 'https://assets.hydralauncher.gg' }}
MAIN_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.EXTERNAL_RESOURCES_URL || 'https://assets.hydralauncher.gg' }}
MAIN_VITE_LAUNCHER_SUBDOMAIN: ${{ vars.MAIN_VITE_LAUNCHER_SUBDOMAIN || '' }}
- name: Upload release assets artifact
uses: actions/upload-artifact@v4
with:
name: release-assets-${{ matrix.os }}
retention-days: 3
path: |
dist/*.exe
dist/*.AppImage
dist/*.snap
dist/*.deb
dist/*.rpm
dist/*.tar.gz
dist/*.yml
dist/*.blockmap
publish-release:
needs: [sync, build]
runs-on: ubuntu-latest
steps:
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
pattern: release-assets-*
path: release-dist
merge-multiple: true
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.sync.outputs.version }}
name: v${{ needs.sync.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
files: release-dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -132,7 +132,7 @@ appImage:
npmRebuild: false
publish:
provider: github
owner: hydralauncher
owner: muriloscolari
repo: hydra
electronDownload:
mirror: https://npmmirror.com/mirrors/electron/