Merge pull request #11 from tailcallhq/fix/publish #14
This file contains 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: Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: [main] | |
types: [opened, reopened, synchronize] | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
# TODO: cancel in progress is not ok for a release since it can be cancelled in a middle of updates | |
# and we can end up with partial release. | |
# but for pull-requests cancelling previously running jobs could be beneficial | |
# cancel-in-progress: true | |
jobs: | |
setup_build_matrix: | |
name: Outputs matrix used for cross compilation | |
uses: ./.github/workflows/build_matrix.yml | |
test_wasm: | |
name: Run Tests (WASM) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
target: wasm32-unknown-unknown | |
- name: Install Wasm Pack | |
run: cargo install wasm-bindgen-cli --vers "0.2.92" | |
- name: Test WASM | |
run: | | |
# TODO: add test for wasm, so we could actually test that. | |
cargo install -q worker-build && worker-build | |
test: | |
name: Run Tests on ${{ matrix.build }} | |
runs-on: ${{ matrix.os || 'ubuntu-latest' }} | |
needs: setup_build_matrix | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.setup_build_matrix.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.11.0" | |
- name: Install Rust Toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Install Cross compilation toolchain | |
uses: taiki-e/setup-cross-toolchain-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
- uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Run Cargo Test | |
if: matrix.test != 'false' | |
# TODO: run llvm-cov only for single build since other builds are not sent to codecov anyway | |
run: cargo llvm-cov --workspace ${{ matrix.features }} --lcov --target ${{ matrix.target }} --output-path lcov.info | |
publish: | |
name: Publish on crates.io | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Log in to Crates.io | |
run: echo ${{ secrets.CARGO_REGISTRY_TOKEN }} | cargo login | |
- name: Publish to Crates.io | |
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |