From 32a1b18c72fcd7778bea557ad378eb2ccaa37452 Mon Sep 17 00:00:00 2001 From: Mega Yu Date: Wed, 15 Apr 2026 20:01:09 +0800 Subject: [PATCH] chore: add update logseq-i18n-lint binary workflow --- .github/workflows/build.yml | 2 +- .github/workflows/update-i18n-lint.yml | 231 +++++++++++++++++++++++++ 2 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-i18n-lint.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b447ace410..93650de435 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -122,7 +122,7 @@ jobs: run: bb lang:validate-translations - name: Lint hardcoded user-facing strings - run: bb lang:lint-hardcoded --warn-only + run: bb lang:lint-hardcoded - name: Lint to keep worker independent of frontend run: bb lint:worker-and-frontend-separate diff --git a/.github/workflows/update-i18n-lint.yml b/.github/workflows/update-i18n-lint.yml new file mode 100644 index 0000000000..ed0490d9a4 --- /dev/null +++ b/.github/workflows/update-i18n-lint.yml @@ -0,0 +1,231 @@ +name: Update logseq-i18n-lint binaries + +on: + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +env: + CARGO_TERM_COLOR: always + LINT_REPO: ${{ github.repository_owner }}/logseq-i18n-lint + LINT_REF: master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout logseq-i18n-lint source + uses: actions/checkout@v4 + with: + repository: ${{ env.LINT_REPO }} + ref: ${{ env.LINT_REF }} + path: lint-src + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo registry and build artifacts + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + lint-src/target/ + key: test-cargo-${{ hashFiles('lint-src/Cargo.lock') }} + restore-keys: | + test-cargo- + + - name: Run tests + working-directory: lint-src + run: cargo test --locked + + build: + needs: test + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-pc-windows-msvc + os: windows-latest + artifact: logseq-i18n-lint-x86_64-windows.exe + - target: aarch64-pc-windows-msvc + os: windows-latest + artifact: logseq-i18n-lint-aarch64-windows.exe + - target: x86_64-apple-darwin + os: macos-latest + artifact: logseq-i18n-lint-x86_64-macos + - target: aarch64-apple-darwin + os: macos-latest + artifact: logseq-i18n-lint-aarch64-macos + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + artifact: logseq-i18n-lint-x86_64-linux + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + artifact: logseq-i18n-lint-aarch64-linux + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout logseq-i18n-lint source + uses: actions/checkout@v4 + with: + repository: ${{ env.LINT_REPO }} + ref: ${{ env.LINT_REF }} + path: lint-src + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache cargo registry and build artifacts + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + lint-src/target/ + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('lint-src/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.target }}-cargo- + ${{ runner.os }}-cargo- + + - name: Install cross (Linux ARM64) + if: matrix.target == 'aarch64-unknown-linux-musl' + run: cargo install cross --git https://github.com/cross-rs/cross + + - name: Install musl tools (Linux x64) + if: matrix.target == 'x86_64-unknown-linux-musl' + run: sudo apt-get update && sudo apt-get install -y musl-tools + + - name: Build with cross + if: matrix.target == 'aarch64-unknown-linux-musl' + working-directory: lint-src + run: cross build --release --target ${{ matrix.target }} + + - name: Build with cargo + if: matrix.target != 'aarch64-unknown-linux-musl' + working-directory: lint-src + run: cargo build --release --target ${{ matrix.target }} + + - name: Stage artifact (Unix) + if: runner.os != 'Windows' + run: cp lint-src/target/${{ matrix.target }}/release/logseq-i18n-lint ${{ matrix.artifact }} + + - name: Stage artifact (Windows) + if: runner.os == 'Windows' + shell: bash + run: cp lint-src/target/${{ matrix.target }}/release/logseq-i18n-lint.exe ${{ matrix.artifact }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: ${{ matrix.artifact }} + + open-pr: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + + - name: Checkout logseq-i18n-lint source + uses: actions/checkout@v4 + with: + repository: ${{ env.LINT_REPO }} + ref: ${{ env.LINT_REF }} + fetch-depth: 0 + path: lint-src + + - name: Download built artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Resolve source commit and stage launcher + id: source + run: | + cd lint-src + COMMIT_SHA="$(git rev-parse HEAD)" + SHORT_SHA="$(git rev-parse --short=12 HEAD)" + echo "commit_sha=${COMMIT_SHA}" >> "$GITHUB_OUTPUT" + echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT" + cd .. + cp lint-src/scripts/logseq-i18n-lint artifacts/logseq-i18n-lint + + - name: Replace bin artifacts + run: | + cp artifacts/logseq-i18n-lint bin/logseq-i18n-lint + cp artifacts/logseq-i18n-lint-aarch64-linux bin/logseq-i18n-lint-aarch64-linux + cp artifacts/logseq-i18n-lint-aarch64-macos bin/logseq-i18n-lint-aarch64-macos + cp artifacts/logseq-i18n-lint-aarch64-windows.exe bin/logseq-i18n-lint-aarch64-windows.exe + cp artifacts/logseq-i18n-lint-x86_64-linux bin/logseq-i18n-lint-x86_64-linux + cp artifacts/logseq-i18n-lint-x86_64-macos bin/logseq-i18n-lint-x86_64-macos + cp artifacts/logseq-i18n-lint-x86_64-windows.exe bin/logseq-i18n-lint-x86_64-windows.exe + chmod +x bin/logseq-i18n-lint bin/logseq-i18n-lint-*-linux bin/logseq-i18n-lint-*-macos 2>/dev/null || true + + - name: Commit updated binaries + id: commit + env: + SHORT_SHA: ${{ steps.source.outputs.short_sha }} + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + BRANCH="chore/update-i18n-lint-${SHORT_SHA}" + git switch -C "${BRANCH}" + git add -A -- \ + bin/logseq-i18n-lint \ + bin/logseq-i18n-lint-aarch64-linux \ + bin/logseq-i18n-lint-aarch64-macos \ + bin/logseq-i18n-lint-aarch64-windows.exe \ + bin/logseq-i18n-lint-x86_64-linux \ + bin/logseq-i18n-lint-x86_64-macos \ + bin/logseq-i18n-lint-x86_64-windows.exe + + if git diff --cached --quiet; then + echo "No changes to commit" + exit 0 + fi + + git commit -m "chore: update logseq-i18n-lint binaries to ${SHORT_SHA}" + git push origin "${BRANCH}" + echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT" + + - name: Open pull request + if: steps.commit.outputs.branch != '' + env: + GH_TOKEN: ${{ github.token }} + COMMIT_SHA: ${{ steps.source.outputs.commit_sha }} + SHORT_SHA: ${{ steps.source.outputs.short_sha }} + BRANCH: ${{ steps.commit.outputs.branch }} + run: | + gh pr create \ + --base develop \ + --head "${BRANCH}" \ + --title "chore: update logseq-i18n-lint binaries to ${SHORT_SHA}" \ + --body "$(cat <