name: Release # Publish by pushing a tag to the gitea remote (`git push gitea v0.5.0`) # or from the Actions tab → Release → Run workflow (enter a version). # # Optional repository variables (Settings → Secrets and variables → Actions → Variables): # PANEL_URL https://panel.example.com — baked into the launcher as the default server # LOCK_PANEL "1" to stop players from changing the server # LAUNCHER_NAME Installer / window name (default "SCOPENET Launcher") on: push: tags: ['v*.*.*'] workflow_dispatch: inputs: version: description: 'Version to release (e.g. 0.2.0)' required: true permissions: contents: read releases: write packages: write env: CARGO_TERM_COLOR: always jobs: version: runs-on: ubuntu-latest outputs: version: ${{ steps.v.outputs.version }} tag: ${{ steps.v.outputs.tag }} steps: - name: Verify Linux runner run: | test "$(uname -s)" = Linux command -v bash - id: v shell: bash env: INPUT_VERSION: ${{ inputs.version }} run: | if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then v="$INPUT_VERSION"; else v="$GITHUB_REF_NAME"; fi v="${v#v}" if ! [[ "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then echo "::error::'$v' is not a semantic version"; exit 1; fi echo "version=$v" >> "$GITEA_OUTPUT" echo "tag=v$v" >> "$GITEA_OUTPUT" launcher: name: Windows installer needs: version runs-on: windows-latest steps: - uses: actions/checkout@v5 - name: Install Windows build dependencies shell: powershell run: .\scripts\ci\install-windows.ps1 - uses: Swatinem/rust-cache@v2 with: key: release - name: Stamp version shell: pwsh env: VERSION: ${{ needs.version.outputs.version }} run: | $cargo = Get-Content Cargo.toml -Raw $cargo = [regex]::new('(?m)^version = ".*"').Replace($cargo, 'version = "' + $env:VERSION + '"', 1) [IO.File]::WriteAllText((Join-Path (Get-Location) 'Cargo.toml'), $cargo) node -e "for(const f of ['launcher/src-tauri/tauri.conf.json','launcher/package.json']){const fs=require('fs');const c=JSON.parse(fs.readFileSync(f));c.version=process.env.VERSION;fs.writeFileSync(f,JSON.stringify(c,null,2))}" - run: npm ci --no-audit --no-fund working-directory: launcher - name: Build installer working-directory: launcher shell: pwsh env: SCOPENET_PANEL_URL: ${{ vars.PANEL_URL }} SCOPENET_LOCK_PANEL: ${{ vars.LOCK_PANEL }} SCOPENET_REPO: ${{ gitea.server_url }}/${{ gitea.repository }} LAUNCHER_NAME: ${{ vars.LAUNCHER_NAME }} run: | if ($env:LAUNCHER_NAME) { $config = node -e "console.log(JSON.stringify({productName: process.env.LAUNCHER_NAME, app: {windows: [{...require('./src-tauri/tauri.conf.json').app.windows[0], title: process.env.LAUNCHER_NAME}]}}))" npx tauri build --bundles nsis --config $config } else { npx tauri build --bundles nsis } if ($LASTEXITCODE -ne 0) { throw "Installer build failed with exit code $LASTEXITCODE" } - name: Collect installer shell: pwsh run: | New-Item -ItemType Directory -Force out | Out-Null Copy-Item target/release/bundle/nsis/*-setup.exe out/ Get-ChildItem out - uses: actions/upload-artifact@v4 with: name: windows-installer path: out/*-setup.exe if-no-files-found: error panel-image: name: Panel image (Gitea registry) needs: version runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - name: Image name run: echo "IMAGE=${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY_OWNER,,}/scopenet-mc-panel" >> "$GITEA_ENV" - name: Stamp version run: sed -i "0,/^version = \".*\"/s//version = \"${{ needs.version.outputs.version }}\"/" Cargo.toml - id: docker run: | if command -v docker >/dev/null && docker info >/dev/null 2>&1; then echo 'ready=true' >> "$GITEA_OUTPUT" else echo 'ready=false' >> "$GITEA_OUTPUT" fi - uses: docker/setup-docker-action@v5 if: steps.docker.outputs.ready != 'true' - uses: docker/setup-buildx-action@v3 - name: Check Linux container dependencies run: bash scripts/ci/install-linux.sh image - uses: docker/login-action@v3 with: registry: gitea.jadonsandbox.com username: ${{ gitea.actor }} password: ${{ secrets.GITEA_TOKEN }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE }} tags: | type=semver,pattern={{version}},value=${{ needs.version.outputs.tag }} type=semver,pattern={{major}}.{{minor}},value=${{ needs.version.outputs.tag }} type=raw,value=latest,enable=${{ !contains(needs.version.outputs.version, '-') }} - uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max server-integrations: needs: version uses: ./.gitea/workflows/integrations.yml with: version: ${{ needs.version.outputs.version }} release: name: Gitea release needs: [version, launcher, panel-image, server-integrations] runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - name: Install Linux release dependencies run: bash scripts/ci/install-linux.sh release - uses: actions/download-artifact@v4 with: name: windows-installer path: dist - uses: actions/download-artifact@v4 with: pattern: server-* merge-multiple: true path: dist - name: Release notes run: | IMAGE="${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY_OWNER,,}/scopenet-mc-panel" cat > notes.md </dev/null; then continue; fi curl --fail-with-body -sS -H "Authorization: token $TOKEN" -F "attachment=@$file" "$api/$id/assets?name=$(basename "$file")" >/dev/null done