From ec46694e325b545ccdeca57799b143dd80daab57 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sat, 18 Nov 2023 22:09:05 -0300 Subject: [PATCH] test ci --- .github/workflows/audit.yml | 33 -- .github/workflows/build-examples.yml | 41 -- .github/workflows/check-packager-binding.yml | 64 --- .github/workflows/check.yml | 82 --- .github/workflows/covector-status.yml | 17 - .../workflows/covector-version-or-publish.yml | 72 --- .github/workflows/integration-tests.yml | 2 +- .github/workflows/publish-packager-nodejs.yml | 465 ------------------ crates/updater/src/lib.rs | 15 + 9 files changed, 16 insertions(+), 775 deletions(-) delete mode 100644 .github/workflows/audit.yml delete mode 100644 .github/workflows/build-examples.yml delete mode 100644 .github/workflows/check-packager-binding.yml delete mode 100644 .github/workflows/check.yml delete mode 100644 .github/workflows/covector-status.yml delete mode 100644 .github/workflows/covector-version-or-publish.yml delete mode 100644 .github/workflows/publish-packager-nodejs.yml diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml deleted file mode 100644 index 32797531..00000000 --- a/.github/workflows/audit.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Audit Rust - -on: - workflow_dispatch: - schedule: - - cron: "0 0 * * *" - push: - branches: - - main - paths: - - ".github/workflows/audit.yml" - - "**/Cargo.lock" - - "**/Cargo.toml" - pull_request: - branches: - - main - paths: - - ".github/workflows/audit.yml" - - "**/Cargo.lock" - - "**/Cargo.toml" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: rustsec/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-examples.yml b/.github/workflows/build-examples.yml deleted file mode 100644 index 0c420b80..00000000 --- a/.github/workflows/build-examples.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Package examples - -on: - pull_request: - branches: - - main - paths: - - ".github/workflows/build-examples.yml" - - "crates/**" - - "examples/**" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - package: - if: ${{ !startsWith(github.head_ref, 'renovate/') }} - strategy: - fail-fast: false - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - - runs-on: ${{ matrix.platform }} - - steps: - - uses: actions/checkout@v4 - - name: install webkit2gtk - if: matrix.platform == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install -y webkit2gtk-4.1 webkit2gtk-4.0 libayatana-appindicator3-dev - - uses: dtolnay/rust-toolchain@stable - - uses: actions/setup-go@v4 - - uses: denoland/setup-deno@v1 - - uses: Swatinem/rust-cache@v2 - - run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - run: cargo install tauri-cli --version "2.0.0-alpha.10" --locked - - run: cargo install dioxus-cli --locked - - run: cargo r --package cargo-packager -- signer generate --password '123' --path ./signing-key -vvv - - run: cargo r --package cargo-packager -- --release --private-key ./signing-key --password '123' --formats all -vvv diff --git a/.github/workflows/check-packager-binding.yml b/.github/workflows/check-packager-binding.yml deleted file mode 100644 index 63ea3cb2..00000000 --- a/.github/workflows/check-packager-binding.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Test `@crabnebula/packager` - -on: - push: - branches: - - main - paths: - - ".github/workflows/check-packager-binding.yml" - - "crates/packager/**" - - "bindings/packager/nodejs/**" - pull_request: - branches: - - main - paths: - - ".github/workflows/check-packager-binding.yml" - - "crates/packager/**" - - "bindings/packager/nodejs/**" - -env: - RUST_BACKTRACE: 1 - CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency. - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - test: - runs-on: ${{ matrix.platform }} - - strategy: - fail-fast: false - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - - steps: - - uses: actions/checkout@v4 - - - name: install Rust stable - uses: dtolnay/rust-toolchain@stable - - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 8.6.4 - - - name: setup node - uses: actions/setup-node@v2 - with: - node-version: 18 - cache: pnpm - cache-dependency-path: bindings/packager/nodejs/pnpm-lock.yaml - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: crates/packager - - - name: test - timeout-minutes: 30 - run: | - cd bindings/packager/nodejs - pnpm install - pnpm build - pnpm test diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 63dad1fe..00000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Check Rust - -on: - push: - branches: - - main - paths: - - ".github/workflows/check.yml" - - "**/*.rs" - - "**/Cargo.toml" - pull_request: - branches: - - main - paths: - - ".github/workflows/check.yml" - - "**/*.rs" - - "**/Cargo.toml" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - fmt: - if: ${{ !startsWith(github.head_ref, 'renovate/') }} - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - name: Check formatting - run: cargo fmt --all -- --check - - clippy: - if: ${{ !startsWith(github.head_ref, 'renovate/') }} - - strategy: - fail-fast: false - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - - runs-on: ${{ matrix.platform }} - - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - name: install webkit2gtk - if: matrix.platform == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install -y webkit2gtk-4.1 libayatana-appindicator3-dev - - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - test: - strategy: - fail-fast: false - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - - runs-on: ${{ matrix.platform }} - - steps: - - uses: actions/checkout@v4 - - name: install webkit2gtk - if: matrix.platform == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install -y webkit2gtk-4.1 libayatana-appindicator3-dev - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo test --workspace --lib --bins --tests --benches --all-features --no-fail-fast - - deny: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 diff --git a/.github/workflows/covector-status.yml b/.github/workflows/covector-status.yml deleted file mode 100644 index 6fd5e47b..00000000 --- a/.github/workflows/covector-status.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Covector Status -on: [pull_request] - -jobs: - covector: - if: ${{ !startsWith(github.head_ref, 'renovate/') }} - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: covector status - uses: jbolda/covector/packages/action@covector-v0 - id: covector - with: - command: "status" diff --git a/.github/workflows/covector-version-or-publish.yml b/.github/workflows/covector-version-or-publish.yml deleted file mode 100644 index 077063a6..00000000 --- a/.github/workflows/covector-version-or-publish.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Covector Version or Publish - -on: - push: - branches: - - main - -jobs: - version-or-publish: - if: ${{ !startsWith(github.head_ref, 'renovate/') }} - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - timeout-minutes: 65 - outputs: - change: ${{ steps.covector.outputs.change }} - commandRan: ${{ steps.covector.outputs.commandRan }} - successfulPublish: ${{ steps.covector.outputs.successfulPublish }} - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: cargo login - run: cargo login ${{ secrets.CRATES_IO_TOKEN }} - - name: git config - run: | - git config --global user.name "${{ github.event.pusher.name }}" - git config --global user.email "${{ github.event.pusher.email }}" - - - name: covector version or publish (publish when no change files present) - uses: jbolda/covector/packages/action@covector-v0 - id: covector - with: - token: ${{ secrets.GITHUB_TOKEN }} - command: "version-or-publish" - createRelease: true - - - name: Create Pull Request With Versions Bumped - if: steps.covector.outputs.commandRan == 'version' - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: release/version-updates - title: "release: apply version updates from current changes" - commit-message: "release: apply version updates from current changes" - labels: "version updates" - body: ${{ steps.covector.outputs.change }} - - - name: Get `@crabnebula/packager` release id - uses: actions/github-script@v6 - id: cliReleaseId - if: | - steps.covector.outputs.successfulPublish == 'true' && - contains(steps.covector.outputs.packagesPublished, '@crabnebula/packager') - with: - result-encoding: string - script: | - const output = `${{ toJSON(steps.covector.outputs) }}`; - const [_, id] = /"-crabnebula-packager-releaseId": "([0-9]+)"/g.exec(output); - return id; - - - name: Trigger `@crabnebula/packager` publishing workflow - if: | - steps.covector.outputs.successfulPublish == 'true' && - contains(steps.covector.outputs.packagesPublished, '@crabnebula/packager') - uses: peter-evans/repository-dispatch@v1 - with: - event-type: publish-packager-nodejs - client-payload: '{"releaseId": "${{ steps.cliReleaseId.outputs.result }}" }' diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index dc9d1a14..21fec5e0 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] + platform: [ubuntu-latest] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish-packager-nodejs.yml b/.github/workflows/publish-packager-nodejs.yml deleted file mode 100644 index 1ace28ab..00000000 --- a/.github/workflows/publish-packager-nodejs.yml +++ /dev/null @@ -1,465 +0,0 @@ -name: Publish `@crabnebula/packager` - -env: - DEBUG: napi:* - APP_NAME: packager - MACOSX_DEPLOYMENT_TARGET: "10.13" - -permissions: - contents: write - id-token: write - -on: - workflow_dispatch: - inputs: - releaseId: - description: "ID of the `@crabnebula/packager` release" - required: true - repository_dispatch: - types: [publish-packager-nodejs] - -defaults: - run: - working-directory: bindings/packager/nodejs - -jobs: - build: - strategy: - fail-fast: false - matrix: - settings: - - host: macos-latest - target: x86_64-apple-darwin - build: | - pnpm build - strip -x *.node - - host: windows-latest - build: pnpm build - target: x86_64-pc-windows-msvc - - host: windows-latest - build: | - pnpm build --target i686-pc-windows-msvc - pnpm test - target: i686-pc-windows-msvc - - host: ubuntu-latest - target: x86_64-unknown-linux-gnu - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian - build: | - cd bindings/packager/nodejs - set -e && - pnpm build --target x86_64-unknown-linux-gnu && - strip *.node - - host: ubuntu-latest - target: x86_64-unknown-linux-musl - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine - build: | - cd bindings/packager/nodejs - set -e - pnpm build - strip *.node - - host: macos-latest - target: aarch64-apple-darwin - build: | - pnpm build --target aarch64-apple-darwin --features native-tls-vendored --cargo-flags="--no-default-features" - strip -x *.node - - host: ubuntu-latest - target: aarch64-unknown-linux-gnu - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 - build: | - cd bindings/packager/nodejs - set -e && - pnpm build --target aarch64-unknown-linux-gnu && - aarch64-unknown-linux-gnu-strip *.node - - host: ubuntu-latest - target: armv7-unknown-linux-gnueabihf - setup: | - sudo apt-get update - sudo apt-get install gcc-arm-linux-gnueabihf -y - build: | - pnpm build --target armv7-unknown-linux-gnueabihf - arm-linux-gnueabihf-strip *.node - - host: ubuntu-latest - target: aarch64-unknown-linux-musl - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine - build: | - cd bindings/packager/nodejs - set -e && - rustup target add aarch64-unknown-linux-musl && - pnpm build --target aarch64-unknown-linux-musl && - /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node - - host: windows-latest - target: aarch64-pc-windows-msvc - build: pnpm build --target aarch64-pc-windows-msvc --features native-tls-vendored --cargo-flags="--no-default-features" - name: stable - ${{ matrix.settings.target }} - node@18 - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v4 - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Setup node - uses: actions/setup-node@v4 - if: ${{ !matrix.settings.docker }} - with: - node-version: 18 - cache: pnpm - cache-dependency-path: bindings/packager/nodejs/pnpm-lock.yaml - - name: Install - uses: dtolnay/rust-toolchain@stable - if: ${{ !matrix.settings.docker }} - with: - toolchain: stable - targets: ${{ matrix.settings.target }} - - name: Cache cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - .cargo-cache - target/ - key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} - - uses: goto-bus-stop/setup-zig@v2 - if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} - with: - version: 0.11.0 - - name: Setup toolchain - run: ${{ matrix.settings.setup }} - if: ${{ matrix.settings.setup }} - shell: bash - - name: Setup node x86 - if: matrix.settings.target == 'i686-pc-windows-msvc' - run: pnpm config set supportedArchitectures.cpu "ia32" - shell: bash - - name: Install dependencies - run: pnpm install - - name: Setup node x86 - uses: actions/setup-node@v4 - if: matrix.settings.target == 'i686-pc-windows-msvc' - with: - node-version: 18 - cache: pnpm - cache-dependency-path: bindings/packager/nodejs/pnpm-lock.yaml - architecture: x86 - - name: Build in docker - uses: addnab/docker-run-action@v3 - if: ${{ matrix.settings.docker }} - with: - image: ${{ matrix.settings.docker }} - options: "--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build" - run: ${{ matrix.settings.build }} - - name: Build - run: ${{ matrix.settings.build }} - if: ${{ !matrix.settings.docker }} - shell: bash - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: bindings-${{ matrix.settings.target }} - path: bindings/packager/nodejs/${{ env.APP_NAME }}.*.node - if-no-files-found: error - test-macOS-windows-binding: - name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - settings: - - host: macos-latest - target: x86_64-apple-darwin - - host: windows-latest - target: x86_64-pc-windows-msvc - node: - - "18" - - "20" - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v4 - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: pnpm - cache-dependency-path: bindings/packager/nodejs/pnpm-lock.yaml - - name: Install dependencies - run: pnpm install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-${{ matrix.settings.target }} - path: bindings/packager/nodejs - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - run: pnpm test - test-linux-x64-gnu-binding: - name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - "18" - - "20" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: pnpm - cache-dependency-path: bindings/packager/nodejs/pnpm-lock.yaml - - name: Install dependencies - run: pnpm install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-unknown-linux-gnu - path: bindings/packager/nodejs - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - working-directory: . - run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim sh -c "cd bindings/packager/nodejs && PACKAGER_FORMATS=deb yarn test" - test-linux-x64-musl-binding: - name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - "18" - - "20" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: pnpm - cache-dependency-path: bindings/packager/nodejs/pnpm-lock.yaml - - name: Install dependencies - run: | - pnpm config set supportedArchitectures.libc "musl" - pnpm install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-unknown-linux-musl - path: bindings/packager/nodejs - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - working-directory: . - run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-alpine sh -c "cd bindings/packager/nodejs && PACKAGER_FORMATS=deb yarn test" - test-linux-aarch64-gnu-binding: - name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - "18" - - "20" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-aarch64-unknown-linux-gnu - path: bindings/packager/nodejs - - name: List packages - run: ls -R . - shell: bash - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Install dependencies - run: | - pnpm config set supportedArchitectures.cpu "arm64" - pnpm config set supportedArchitectures.libc "glibc" - pnpm install - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: node:${{ matrix.node }}-slim - options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build" - run: | - export PACKAGER_FORMATS=deb - set -e - cd bindings/packager/nodejs - yarn test - ls -la - test-linux-aarch64-musl-binding: - name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} - needs: - - build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-aarch64-unknown-linux-musl - path: bindings/packager/nodejs - - name: List packages - run: ls -R . - shell: bash - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Install dependencies - run: | - pnpm config set supportedArchitectures.cpu "arm64" - pnpm config set supportedArchitectures.libc "musl" - pnpm install - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: node:lts-alpine - options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build" - run: | - export PACKAGER_FORMATS=deb - set -e - cd bindings/packager/nodejs - yarn test - test-linux-arm-gnueabihf-binding: - name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - "18" - - "20" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-armv7-unknown-linux-gnueabihf - path: bindings/packager/nodejs - - name: List packages - run: ls -R . - shell: bash - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Install dependencies - run: | - pnpm config set supportedArchitectures.cpu "arm" - pnpm install - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: node:${{ matrix.node }}-bullseye-slim - options: "--platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build" - run: | - export PACKAGER_FORMATS=deb - set -e - cd bindings/packager/nodejs - yarn test - ls -la - publish: - name: Publish - runs-on: ubuntu-latest - needs: - - test-macOS-windows-binding - - test-linux-x64-gnu-binding - - test-linux-x64-musl-binding - - test-linux-aarch64-gnu-binding - - test-linux-aarch64-musl-binding - - test-linux-arm-gnueabihf-binding - steps: - - uses: actions/checkout@v4 - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - package_json_file: bindings/packager/nodejs - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: pnpm - cache-dependency-path: bindings/packager/nodejs/pnpm-lock.yaml - - name: Install dependencies - run: pnpm install - - name: Download all artifacts - uses: actions/download-artifact@v3 - with: - path: bindings/packager/nodejs/artifacts - - name: Move artifacts - run: pnpm artifacts - - name: List packages - run: ls -R ./npm - shell: bash - - name: Publish - run: | - npm config set provenance true - if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; - then - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - npm publish --access public - elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; - then - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - npm publish --tag next --access public - else - echo "Not a release, skipping publish" - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - RELEASE_ID: ${{ github.event.client_payload.releaseId || inputs.releaseId }} diff --git a/crates/updater/src/lib.rs b/crates/updater/src/lib.rs index 18816c28..e2dce3e1 100644 --- a/crates/updater/src/lib.rs +++ b/crates/updater/src/lib.rs @@ -505,6 +505,7 @@ impl Update { /// Installs the updater package downloaded by [`Update::download`] pub fn install(&self, bytes: Vec) -> Result<()> { + println!("install"); self.install_inner(bytes) } @@ -672,34 +673,48 @@ impl Update { for tmp_dir_location in tmp_dir_locations { if let Some(tmp_dir) = tmp_dir_location() { + println!("tmp {:?}", tmp_dir); use std::os::unix::fs::{MetadataExt, PermissionsExt}; let tmp_dir_metadata = tmp_dir.metadata()?; if extract_path_metadata.dev() == tmp_dir_metadata.dev() { + println!("same fs"); let mut perms = tmp_dir_metadata.permissions(); perms.set_mode(0o700); std::fs::set_permissions(&tmp_dir, perms)?; + println!("set perms"); + let (_, tmp_app_image) = tempfile::Builder::new() .prefix("current_app") .suffix(".AppImage") .tempfile_in(tmp_dir)? .keep()?; + println!("created tmp {:?}", tmp_app_image); + // get metadata to restore later let metadata = self.extract_path.metadata()?; + println!("got metadata"); + // create a backup of our current app image std::fs::rename(&self.extract_path, &tmp_app_image)?; + println!("renamed"); + // if something went wrong during the extraction, we should restore previous app if let Err(err) = std::fs::write(&self.extract_path, bytes).and_then(|_| { + println!("wrote"); std::fs::set_permissions(&self.extract_path, metadata.permissions()) }) { + println!("err :( {err}"); std::fs::rename(tmp_app_image, &self.extract_path)?; return Err(err.into()); } + println!("done"); + // early finish we have everything we need here return Ok(()); }