From 24d082e6a69cc5c8cdd5b4ff13e45ff440f31163 Mon Sep 17 00:00:00 2001 From: didirus Date: Wed, 17 Jun 2026 02:33:11 +0300 Subject: [PATCH] ci: remove unused upstream workflows and enable macOS build --- .github/workflows/api-client-release.yml | 125 ---------------- .github/workflows/astralrinth-build.yml | 140 ++++++++++-------- .../workflows/cancel-pr-workflow-on-merge.yml | 22 --- .github/workflows/changelog-comment.yml | 121 --------------- .github/workflows/prepare-pnpm-cache.yml | 41 ----- 5 files changed, 76 insertions(+), 373 deletions(-) delete mode 100644 .github/workflows/api-client-release.yml delete mode 100644 .github/workflows/cancel-pr-workflow-on-merge.yml delete mode 100644 .github/workflows/changelog-comment.yml delete mode 100644 .github/workflows/prepare-pnpm-cache.yml diff --git a/.github/workflows/api-client-release.yml b/.github/workflows/api-client-release.yml deleted file mode 100644 index 9f777e913..000000000 --- a/.github/workflows/api-client-release.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: API client release - -on: - push: - branches: [main] - paths: - - .github/workflows/api-client-release.yml - - packages/api-client/** - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false - -permissions: - contents: read - id-token: write - -jobs: - release: - if: github.repository_owner == 'modrinth' && github.ref == 'refs/heads/main' - # npm Trusted Publishing requires a GitHub-hosted runner. - runs-on: ubuntu-latest - env: - FORCE_COLOR: 3 - PACKAGE_DIR: packages/api-client - PACKAGE_NAME: '@modrinth/api-client' - BUMP_TYPE: minor - steps: - - name: Check out code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - - - name: Check for api-client changes - id: changes - run: | - if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then - echo "changed=true" >> "$GITHUB_OUTPUT" - exit 0 - fi - - if git diff --quiet "${{ github.event.before }}" "$GITHUB_SHA" -- "$PACKAGE_DIR"; then - echo "changed=false" >> "$GITHUB_OUTPUT" - else - echo "changed=true" >> "$GITHUB_OUTPUT" - fi - - - name: Setup Node - if: steps.changes.outputs.changed == 'true' - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: .nvmrc - registry-url: https://registry.npmjs.org - - - name: Enable Corepack - if: steps.changes.outputs.changed == 'true' - run: corepack enable - - - name: Get pnpm store path - if: steps.changes.outputs.changed == 'true' - id: pnpm-store - run: echo "store-path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" - - - name: Restore pnpm cache - if: steps.changes.outputs.changed == 'true' - uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: ${{ steps.pnpm-store.outputs.store-path }} - key: pnpm-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - pnpm-cache- - - - name: Install dependencies - if: steps.changes.outputs.changed == 'true' - run: pnpm install --frozen-lockfile --filter @modrinth/api-client... - - - name: Resolve release version - if: steps.changes.outputs.changed == 'true' - id: version - run: | - CURRENT_VERSION_JSON="$(npm view "${PACKAGE_NAME}" version --json)" - CURRENT_VERSION="$( - jq -nr \ - --argjson version "$CURRENT_VERSION_JSON" \ - 'if ($version | type) == "array" then $version[-1] else $version end' - )" - - NEXT_VERSION="$( - jq -nr \ - --arg version "$CURRENT_VERSION" \ - --arg bump "$BUMP_TYPE" ' - def semver: - capture("^(?[0-9]+)\\.(?[0-9]+)\\.(?[0-9]+)$") - | with_entries(.value |= tonumber); - - ($version | semver) as $current - | if $bump == "major" then "\($current.major + 1).0.0" - elif $bump == "minor" then "\($current.major).\($current.minor + 1).0" - elif $bump == "patch" then "\($current.major).\($current.minor).\($current.patch + 1)" - else error("Unsupported bump type: \($bump)") - end - ' - )" - - PACKAGE_JSON="$(mktemp)" - jq --tab --arg version "$NEXT_VERSION" '.version = $version' "$PACKAGE_DIR/package.json" > "$PACKAGE_JSON" - mv "$PACKAGE_JSON" "$PACKAGE_DIR/package.json" - - echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" - echo "published_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" - echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT" - - - name: Build api-client - if: steps.changes.outputs.changed == 'true' - run: pnpm --filter @modrinth/api-client build - - - name: Check package contents - if: steps.changes.outputs.changed == 'true' - working-directory: packages/api-client - run: pnpm pack --dry-run - - - name: Publish api-client - if: steps.changes.outputs.changed == 'true' - working-directory: packages/api-client - run: pnpm publish --access public --provenance --no-git-checks diff --git a/.github/workflows/astralrinth-build.yml b/.github/workflows/astralrinth-build.yml index 63bb12c65..c13f78cfa 100644 --- a/.github/workflows/astralrinth-build.yml +++ b/.github/workflows/astralrinth-build.yml @@ -1,4 +1,4 @@ -name: AstralRinth App build +name: AstralRinth App Build on: push: @@ -21,25 +21,38 @@ on: - 'packages/assets/**' - 'packages/ui/**' - 'packages/utils/**' + - 'package.json' + - 'pnpm-lock.yaml' + - 'pnpm-workspace.yaml' + - 'turbo.jsonc' + - 'mise.toml' + - 'rust-toolchain.toml' workflow_dispatch: +concurrency: + group: astralrinth-build-${{ github.ref }} + cancel-in-progress: true + jobs: build: - name: Build + name: ${{ matrix.label }} + runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: - # platform: [macos-latest, windows-latest, ubuntu-latest] - platform: [windows-latest, ubuntu-latest] include: - # - platform: macos-latest - # artifact-target-name: universal-apple-darwin - - platform: windows-latest - artifact-target-name: x86_64-pc-windows-msvc - - platform: ubuntu-latest - artifact-target-name: x86_64-unknown-linux-gnu + - runner: ubuntu-latest + label: ๐Ÿง Linux Build + artifact_name: astralrinth-bundle-linux + - runner: windows-latest + label: ๐ŸชŸ Windows Build + artifact_name: astralrinth-bundle-windows + - runner: macos-latest + label: ๐ŸŽ macOS Build + artifact_name: astralrinth-bundle-macos - runs-on: ${{ matrix.platform }} + env: + CI: true steps: - name: ๐Ÿ“ฅ Check out code @@ -63,25 +76,31 @@ jobs: fi if [ "$eol_setting" = "crlf" ]; then - echo "โš ๏ธ WARNING: core.eol is set to 'crlf'. Consider unsetting it or setting to 'lf'." + echo "โš ๏ธ WARNING: core.eol is set to 'crlf'. Consider unsetting it or setting it to 'lf'." fi - name: ๐Ÿ” Check migration files line endings (LF only) shell: bash run: | echo "๐Ÿ” Scanning migration SQL files for CR characters (\\r)..." + if grep -Iq $'\r' packages/app-lib/migrations/*.sql; then - echo "โŒ ERROR: Some migration files contain CR (\\r) characters โ€” expected only LF line endings." + echo "โŒ ERROR: Some migration files contain CR characters; expected LF-only files." exit 1 fi - echo "โœ… All migration files use LF line endings" + + echo "โœ… All migration files use LF line endings." - name: ๐Ÿงฐ Setup Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - target: ${{ matrix.artifact-target-name }} - - name: ๐Ÿงฐ Install pnpm + - name: โ˜• Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + + - name: ๐Ÿงฐ Setup pnpm uses: pnpm/action-setup@v4 - name: ๐Ÿงฐ Setup Node.js @@ -90,69 +109,62 @@ jobs: node-version-file: .nvmrc cache: pnpm - - name: ๐Ÿงฐ Install Linux build dependencies - if: matrix.platform == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install -yq \ - libgtk-3-dev \ - libwebkit2gtk-4.1-dev \ - libayatana-appindicator3-dev \ - librsvg2-dev \ - xdg-utils \ - openjdk-17-jdk + - name: ๐Ÿงฐ Setup mise + uses: jdx/mise-action@v2 + with: + install: true + cache: true - - name: โš™๏ธ Set application environment - shell: bash - run: | - cp packages/app-lib/.env.prod packages/app-lib/.env + - name: ๐Ÿฆ€ Cache Rust build artifacts + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + . -> target + cache-on-failure: true - name: ๐Ÿ’จ Setup Turbo cache uses: rharkor/caching-for-turbo@v1.8 - - name: ๐Ÿงฐ Install dependencies - run: pnpm install - - - name: โœ๏ธ Set up Windows code signing (jsign) - if: matrix.platform == 'windows-latest' && env.SIGN_WINDOWS_BINARIES == 'true' + - name: ๐Ÿง Install Linux build dependencies + if: matrix.runner == 'ubuntu-latest' shell: bash run: | - choco install jsign --ignore-dependencies + sudo apt-get update + sudo apt-get install -yq \ + build-essential \ + curl \ + file \ + libayatana-appindicator3-dev \ + libgtk-3-dev \ + librsvg2-dev \ + libssl-dev \ + libwebkit2gtk-4.1-dev \ + patchelf \ + xdg-utils - - name: ๐Ÿ—‘๏ธ Clean up cached bundles + - name: โš™๏ธ Set application environment + shell: bash + run: cp packages/app-lib/.env.prod packages/app-lib/.env + + - name: ๐Ÿ“ฆ Install dependencies + shell: bash + run: pnpm install --frozen-lockfile + + - name: ๐Ÿงน Clean previous bundles shell: bash run: | rm -rf target/release/bundle rm -rf target/*/release/bundle || true - # - name: ๐Ÿ”จ Build macOS app - # if: matrix.platform == 'macos-latest' - # run: pnpm --filter=@modrinth/app run tauri build --target universal-apple-darwin --config tauri-release.conf.json - # env: - # TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - # TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - - - name: ๐Ÿ”จ Build Linux app - if: matrix.platform == 'ubuntu-latest' - run: pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json - env: - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - - - name: ๐Ÿ”จ Build Windows app - if: matrix.platform == 'windows-latest' - shell: pwsh - run: | - $env:JAVA_HOME = "$env:JAVA_HOME_17_X64" - pnpm --filter=@modrinth/app run tauri build --config tauri-release.conf.json --verbose --bundles 'nsis' - env: - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} + - name: ๐Ÿ”จ Build app + shell: bash + run: mise exec -- pnpm app:build - name: ๐Ÿ“ค Upload app bundles - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: App bundle (${{ matrix.artifact-target-name }}) + name: ${{ matrix.artifact_name }} path: | target/release/bundle/** target/*/release/bundle/** + if-no-files-found: error diff --git a/.github/workflows/cancel-pr-workflow-on-merge.yml b/.github/workflows/cancel-pr-workflow-on-merge.yml deleted file mode 100644 index 3f3eec12d..000000000 --- a/.github/workflows/cancel-pr-workflow-on-merge.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Cancel PR Workflows on Merge - -on: - pull_request_target: - types: - - closed - -permissions: - actions: write - -jobs: - cancel: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1 - with: - workflow_id: all - access_token: ${{ secrets.GITHUB_TOKEN }} - ignore_sha: true - pr_number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/changelog-comment.yml b/.github/workflows/changelog-comment.yml deleted file mode 100644 index 79937c7a3..000000000 --- a/.github/workflows/changelog-comment.yml +++ /dev/null @@ -1,121 +0,0 @@ -name: Changelog Comment - -on: - pull_request_target: - types: [opened, reopened] - workflow_dispatch: - inputs: - pr_number: - description: 'PR number to post the changelog comment on (for testing)' - required: true - type: number - -jobs: - comment: - name: Post changelog comment - runs-on: ubuntu-latest - - steps: - - name: Post or update changelog comment - uses: actions/github-script@d746ffe35508b1917358783b479e04febd2b8f71 # v9.0.0 - with: - github-token: ${{ secrets.CROWDIN_GH_TOKEN }} - script: | - const marker = ''; - const mergedMarker = ''; - - const sections = ['### Added', '', '### Changed', '', '### Deprecated', '', '### Removed', '', '### Fixed', '', '### Security'].join('\n'); - const productBlock = (name) => `
\n${name}\n\n${sections}\n\n
`; - - const template = [ - marker, - '## Pull request changelog', - '', - '', - '', - productBlock('App'), - '', - productBlock('Website'), - '', - productBlock('Hosting'), - ].join('\n'); - - // Resolve PR number from event or workflow_dispatch input - const prNumber = context.payload.pull_request?.number - ?? parseInt('${{ github.event.inputs.pr_number }}', 10); - - if (!prNumber || isNaN(prNumber)) { - core.setFailed('Could not determine PR number'); - return; - } - - // Get PR details (need base ref for child PR detection) - const { data: pr } = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: prNumber, - }); - - // Check if bot comment already exists - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - }); - - const existingComment = comments.find(c => c.body.includes(marker)); - if (existingComment) { - core.info('Changelog comment already exists, skipping'); - return; - } - - // Post the template comment - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - body: template, - }); - - core.info(`Posted changelog comment on PR #${prNumber}`); - - // Detect child PR: check if this PR's base branch is another open PR's head branch - const baseRef = pr.base.ref; - - if (baseRef === 'main' || baseRef === 'prod') { - return; - } - - // Look for a parent PR whose head branch matches our base branch - const { data: candidatePRs } = await github.rest.pulls.list({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open', - head: `${context.repo.owner}:${baseRef}`, - }); - - if (candidatePRs.length === 0) { - return; - } - - const parentPR = candidatePRs[0]; - core.info(`Detected parent PR #${parentPR.number} for child PR #${prNumber}`); - - // Add admonition to child PR's changelog comment - const { data: childComments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - }); - - const childChangelogComment = childComments.find(c => c.body.includes(marker)); - if (childChangelogComment && !childChangelogComment.body.includes(mergedMarker)) { - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: childChangelogComment.id, - body: `${mergedMarker}\n> [!NOTE]\n> This changelog has been merged into the changelog for #${parentPR.number}\n\n${childChangelogComment.body}`, - }); - } diff --git a/.github/workflows/prepare-pnpm-cache.yml b/.github/workflows/prepare-pnpm-cache.yml deleted file mode 100644 index 16c563c94..000000000 --- a/.github/workflows/prepare-pnpm-cache.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Prepare pnpm cache - -on: - push: - paths: - - .github/workflows/prepare-pnpm-cache.yml - - package.json - - pnpm-lock.yaml - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/prod' }} - -jobs: - prepare: - if: github.repository_owner == 'modrinth' - runs-on: blacksmith-2vcpu-ubuntu-2404 - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Setup Node - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: .nvmrc - - - name: Enable Corepack - run: corepack enable - - - name: Get pnpm store path - id: pnpm-store - run: echo "store-path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - - - name: Cache pnpm - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: ${{ steps.pnpm-store.outputs.store-path }} - key: pnpm-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/pnpm-lock.yaml') }} - - - name: Install dependencies - run: pnpm recursive install --frozen-lockfile