From acf3a814bd93a1d7351a38aa653a6fc3f8638b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sun, 23 Feb 2025 17:53:19 +0000 Subject: [PATCH] ci: Gitea actions (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.unlock-music.dev/um/lib_um_crypto_rust/pulls/8 Co-authored-by: 鲁树人 Co-committed-by: 鲁树人 --- .drone.yml | 38 ------------------------------- .gitea/workflows/build.yaml | 44 ++++++++++++++++++++++++++++++++++++ um_wasm_loader/ci_publish.sh | 2 +- um_wasm_loader/package.json | 2 +- 4 files changed, 46 insertions(+), 40 deletions(-) delete mode 100644 .drone.yml create mode 100644 .gitea/workflows/build.yaml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 3b76551..0000000 --- a/.drone.yml +++ /dev/null @@ -1,38 +0,0 @@ -kind: pipeline -type: docker -name: default - -when: - event: - - push - - pull_request - - tag - -steps: - -- name: test - image: rust:1.81-bookworm - commands: - - cargo test --verbose --all - -- name: build (wasm_pack) - image: rust:1.81-bookworm - commands: - - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - - (cd um_wasm && wasm-pack build --release --target web --out-dir ../um_wasm_loader/pkg) - -- name: build (node) - image: node:22.9-bookworm - environment: - NPM_TOKEN: - from_secret: NPM_TOKEN - COREPACK_ENABLE_AUTO_PIN: 0 - BUILD_SKIP_WASM_PACK: 1 - depends_on: - - "build (wasm_pack)" - commands: - - corepack enable - - cd um_wasm_loader - - pnpm i - - pnpm build - - ./ci_publish.sh diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..02e2490 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,44 @@ +name: Build and Publish +on: + push: + branches: + - main + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + env: + COREPACK_ENABLE_AUTO_PIN: 0 + BUILD_SKIP_WASM_PACK: 1 + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + - name: Test + run: cargo test --verbose --all + - name: Setup wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + - name: Build (rust to wasm) + run: | + cd um_wasm + wasm-pack build --release --target web --out-dir ../um_wasm_loader/pkg + - name: Setup pnpm + uses: pnpm/action-setup@v4.0.0 + with: + standalone: true + package_json_file: um_wasm_loader/package.json + run_install: | + - cwd: um_wasm_loader + args: [--frozen-lockfile, --strict-peer-dependencies] + - name: Build (wasm) + working-directory: um_wasm_loader + run: pnpm build + - name: Publish + working-directory: um_wasm_loader + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: ./ci_publish.sh diff --git a/um_wasm_loader/ci_publish.sh b/um_wasm_loader/ci_publish.sh index e4f12fd..56268aa 100755 --- a/um_wasm_loader/ci_publish.sh +++ b/um_wasm_loader/ci_publish.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [[ -z "${DRONE_TAG}" ]]; then +if [[ ! "$GITHUB_REF" =~ ^refs/tags/ ]]; then echo "skip package publish, pack only." pnpm pack exit 0 diff --git a/um_wasm_loader/package.json b/um_wasm_loader/package.json index 18be024..e0040be 100644 --- a/um_wasm_loader/package.json +++ b/um_wasm_loader/package.json @@ -1,5 +1,5 @@ { - "packageManager": "pnpm@9.12.1+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4", + "packageManager": "pnpm@10.4.0", "name": "@unlock-music/crypto", "version": "0.1.2", "description": "Project Unlock Music: 加解密支持库",