Download artifacts to the dist folder #15
Workflow file for this run
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: | |
| push: | |
| tags: ["v*"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| cargo: | |
| name: Publish to crates.io | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Authenticate with crates.io | |
| uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4 | |
| id: auth | |
| - name: Publish to crates.io | |
| run: cargo publish | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| code-target: win32-x64 | |
| - os: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| code-target: win32-arm64 | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| code-target: linux-x64 | |
| - os: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| code-target: linux-arm64 | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| code-target: linux-x64-musl | |
| - os: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-musl | |
| code-target: linux-arm64-musl | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| code-target: darwin-x64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| code-target: darwin-arm64 | |
| name: Build ${{ matrix.code-target }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install Rust toolchain | |
| run: rustup target add ${{ matrix.target }} | |
| - name: Install musl tools | |
| if: contains(matrix.code-target, 'musl') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y musl-tools | |
| - name: Build binary | |
| run: cargo build -p browsercfg --release --target ${{ matrix.target }} | |
| env: | |
| RUSTFLAGS: "-C strip=symbols -C codegen-units=1" | |
| - name: Copy binary (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| mkdir dist | |
| cp target/${{ matrix.target }}/release/browsercfg.exe ./dist/browsercfg-${{ matrix.code-target }}.exe | |
| - name: Copy binary (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| mkdir dist | |
| cp target/${{ matrix.target }}/release/browsercfg ./dist/browsercfg-${{ matrix.code-target }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: browsercfg-${{ matrix.target }} | |
| path: ./dist/browsercfg-* | |
| if-no-files-found: error | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| pattern: browsercfg-* | |
| merge-multiple: true | |
| path: dist | |
| - name: Install Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| package-manager-cache: false | |
| - name: Generate npm packages | |
| run: node npm/scripts/generate-packages.mjs ${{ github.ref_name }} | |
| - name: Publish npm packages | |
| run: | | |
| npm publish ./npm/ | |
| for package in browsercfg-*/; do | |
| npm publish $package | |
| done | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 | |
| with: | |
| files: browsercfg-* | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |