Release #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| type: choice | |
| description: 'Release Version' | |
| required: true | |
| default: 'latest' | |
| options: | |
| - next | |
| - beta | |
| - alpha | |
| - latest | |
| branch: | |
| description: 'Release Branch' | |
| required: true | |
| default: 'main' | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| release: | |
| name: Release | |
| if: github.event_name == 'workflow_dispatch' || github.event.comment.body == '/release' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 25 | |
| ref: ${{ github.event.inputs.branch || github.ref }} | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Install pnpm | |
| run: corepack enable | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: 'pnpm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install Dependencies | |
| run: pnpm install | |
| - name: Build @veaba/qrcode-js-shared | |
| run: pnpm --filter @veaba/qrcode-js-shared build | |
| - name: Build @veaba/qrcode-wasm | |
| run: pnpm --filter @veaba/qrcode-wasm build | |
| - name: Build @veaba/qrcode-js | |
| run: pnpm --filter @veaba/qrcode-js build | |
| - name: Build @veaba/qrcode-node | |
| run: pnpm --filter @veaba/qrcode-node build | |
| - name: Build @veaba/qrcode-bun | |
| run: pnpm --filter @veaba/qrcode-bun build | |
| # ======================================== | |
| # Publish Rust Crates to crates.io | |
| # ======================================== | |
| # 由 changesets 管理版本号,如果 crates.io 已存在同版本则跳过 | |
| - name: Get versions from package.json | |
| id: versions | |
| run: | | |
| echo "qrcode_rust_shared=$(node -p "require('./packages/qrcode-rust-shared/package.json').version")" >> $GITHUB_OUTPUT | |
| echo "qrcode_rust=$(node -p "require('./packages/qrcode-rust/package.json').version")" >> $GITHUB_OUTPUT | |
| echo "qrcode_fast=$(node -p "require('./packages/qrcode-fast/package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Publish qrcode-rust-shared to crates.io | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.versions.outputs.qrcode_rust_shared }}" | |
| if cargo search qrcode-rust-shared --limit 1 2>/dev/null | grep -q "qrcode-rust-shared = \"$VERSION\""; then | |
| echo "✅ qrcode-rust-shared v$VERSION already exists, skipping" | |
| else | |
| echo "📦 Publishing qrcode-rust-shared v$VERSION..." | |
| cargo publish -p qrcode-rust-shared --token "$CARGO_REGISTRY_TOKEN" | |
| echo "✅ qrcode-rust-shared published" | |
| fi | |
| - name: Wait for crates.io index | |
| run: sleep 30 | |
| - name: Publish qrcode-rust to crates.io | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| continue-on-error: true | |
| run: | | |
| VERSION="${{ steps.versions.outputs.qrcode_rust }}" | |
| if cargo search qrcode-rust --limit 1 2>/dev/null | grep -q "qrcode-rust = \"$VERSION\""; then | |
| echo "✅ qrcode-rust v$VERSION already exists, skipping" | |
| else | |
| echo "📦 Publishing qrcode-rust v$VERSION..." | |
| for i in 1 2 3; do | |
| if cargo publish -p qrcode-rust --token "$CARGO_REGISTRY_TOKEN" 2>&1; then | |
| echo "✅ qrcode-rust published" | |
| exit 0 | |
| fi | |
| echo "⚠️ Attempt $i failed, retrying in 30s..." | |
| sleep 30 | |
| done | |
| echo "❌ Failed to publish qrcode-rust" | |
| exit 1 | |
| fi | |
| - name: Publish qrcode-fast to crates.io | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| continue-on-error: true | |
| run: | | |
| VERSION="${{ steps.versions.outputs.qrcode_fast }}" | |
| if cargo search qrcode-fast --limit 1 2>/dev/null | grep -q "qrcode-fast = \"$VERSION\""; then | |
| echo "✅ qrcode-fast v$VERSION already exists, skipping" | |
| else | |
| echo "📦 Publishing qrcode-fast v$VERSION..." | |
| for i in 1 2 3; do | |
| if cargo publish -p qrcode-fast --token "$CARGO_REGISTRY_TOKEN" 2>&1; then | |
| echo "✅ qrcode-fast published" | |
| exit 0 | |
| fi | |
| echo "⚠️ Attempt $i failed, retrying in 30s..." | |
| sleep 30 | |
| done | |
| echo "❌ Failed to publish qrcode-fast" | |
| exit 1 | |
| fi | |
| - name: Create Release Pull Request or Publish | |
| uses: changesets/action@v1 | |
| with: | |
| version: pnpm ci:version | |
| publish: pnpm ci:publish | |
| commit: "chore: version packages" | |
| title: "chore: version packages" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |