π Release #7
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: π Release | |
on: | |
workflow_dispatch: | |
inputs: | |
force-publish: | |
required: true | |
type: boolean | |
description: Publish Releases at Anytime | |
workflow_run: | |
workflows: [ π§ͺ Tests and Checks ] | |
branches: [main] | |
types: [ completed ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release-please: | |
runs-on: ubuntu-latest | |
if: > | |
github.ref == 'refs/heads/main' && | |
github.repository_owner == 'fission-codes' && | |
github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' | |
outputs: | |
releases_created: ${{ steps.release.outputs['car-mirror--release_created'] || steps.release.outputs['car-mirror-wasm--release_created'] }} | |
wasm_release_created: ${{ steps.release.outputs['car-mirror-wasm--release_created'] }} | |
steps: | |
- name: Run release-please | |
id: release | |
uses: google-github-actions/release-please-action@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
default-branch: main | |
command: manifest | |
extra-files: | | |
README.md | |
publish-release-crates: | |
if: ${{ needs.release-please.outputs.releases_created || github.event.inputs.force-publish }} | |
runs-on: ubuntu-latest | |
needs: [ release-please ] | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Cache Project | |
uses: Swatinem/rust-cache@v2 | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
profile: minimal | |
toolchain: stable | |
- name: Install Cargo Workspaces | |
env: | |
RUSTFLAGS: '-Copt-level=1' | |
uses: actions-rs/cargo@v1 | |
with: | |
args: --force cargo-workspaces | |
command: install | |
- name: Verify Publishing of crate | |
uses: katyo/publish-crates@v2 | |
with: | |
dry-run: true | |
- name: Cargo Publish to crates.io | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
run: cargo workspaces publish --from-git | |
publish-release-npm: | |
if: ${{ needs.release-please.outputs.wasm_release_created || github.event.inputs.force-publish }} | |
runs-on: ubuntu-latest | |
needs: [ release-please ] | |
permissions: | |
contents: write | |
defaults: | |
run: | |
working-directory: ./car-mirror-wasm | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Cache Project | |
uses: Swatinem/rust-cache@v2 | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
profile: minimal | |
toolchain: stable | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
# Builds output via wasm-pack and renames package.json name to remove | |
# `-wasm`. | |
- name: Build | |
run: | | |
wasm-pack build --target web --out-name car-mirror | |
sed -i -e 's/"name": "car-mirror-wasm"/"name": "car-mirror",\n "type": "module"/g' pkg/package.json | |
- name: Publish to npm | |
run: wasm-pack publish | |
working-directory: pkg | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |