aquavm/.github/workflows/snapshot.yml
Ivan Boldyrev ea934ab9a9
air-beautify-wasm in the tree (#336)
1. Update wasm-bindgen in the wasm-air-beautify to make it buildable with rest of tree.
2. Rename `wasm-air-beautify` to `air-beautify-wasm`, to make it consistent
   with other packages.
3. Implement github workflows to build and deploy the `air-beautify-wasm` package.
2022-10-25 14:54:51 +07:00

338 lines
11 KiB
YAML

name: Publish snapshots
on:
workflow_call:
outputs:
avm-version:
description: "@fluencelabs/avm version"
value: ${{ jobs.publish-avm.outputs.version }}
air-interpreter-wasm-version:
description: "air-interpreter-wasm version"
value: ${{ jobs.publish-interpreter.outputs.version }}
air-beautify-wasm-version:
description: "air-beautify-wasm version"
value: ${{ jobs.publish-beautify.outputs.version }}
env:
FORCE_COLOR: true
jobs:
wasm:
name: "Build air-interpreter-wasm"
runs-on: ubuntu-latest
steps:
- name: Checkout AquaVM
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install marine
uses: baptiste0928/cargo-install@v1
with:
crate: marine
- name: Build air-interpreter-wasm binary
run: marine build --release --features marine
working-directory: air-interpreter
- name: Upload air-interpreter-wasm binary
uses: actions/upload-artifact@v3
with:
name: air-interpreter-wasm
path: target/wasm32-wasi/release/air_interpreter_server.wasm
publish-avm:
name: "Publish avm snapshot"
runs-on: ubuntu-latest
needs: wasm
outputs:
version: "${{ steps.build.outputs.version }}"
permissions:
contents: read
pull-requests: write
id-token: write
steps:
- name: Checkout AquaVM
uses: actions/checkout@v3
- name: Download air-interpreter-wasm binary
uses: actions/download-artifact@v3
with:
name: air-interpreter-wasm
path: avm/client/dist/
- run: mv air_interpreter_server.wasm avm.wasm
working-directory: avm/client/dist
- name: Import secrets
uses: hashicorp/vault-action@v2.4.2
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
- name: Setup node with self-hosted npm registry
uses: actions/setup-node@v3
with:
node-version: "16"
registry-url: "https://npm.fluence.dev"
cache-dependency-path: avm/client/package-lock.json
cache: "npm"
- run: npm i
working-directory: avm/client
- run: npm run build
working-directory: avm/client
- name: Generate package version
id: version
run: |
SHA=${{ github.event.pull_request.head.sha }}
echo "::set-output name=sha::${SHA::7}"
echo "::set-output name=branch::${GITHUB_HEAD_REF//[^a-zA-Z0-9-]/-}"
echo "::set-output name=avm::$(cargo read-manifest --manifest-path air-interpreter/Cargo.toml | jq -r .version)"
- name: Set package version
id: build
env:
VERSION: ${{ steps.version.outputs.avm }}
BRANCH: ${{ steps.version.outputs.branch }}
SHA: ${{ steps.version.outputs.sha }}
RUN: ${{ github.run_number }}
ATTEMPT: ${{ github.run_attempt }}
working-directory: avm/client
run: |
echo "::set-output name=version::$(\
npm version --no-git-tag-version \
${{ env.VERSION }}-${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }})"
- name: Publish to self-hosted npm repo
working-directory: avm/client
run: npm publish --tag snapshot --registry https://npm.fluence.dev
- name: Find comment in PR
uses: peter-evans/find-comment@v1
id: comment
with:
issue-number: "${{ github.event.pull_request.number }}"
comment-author: github-actions[bot]
body-includes: "## AVM version is"
- name: Update comment in PR
uses: peter-evans/create-or-update-comment@v1
env:
AVM_VERSION: ${{ steps.build.outputs.version }}
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
edit-mode: replace
body: |
## AVM version is [${{ env.AVM_VERSION }}](https://npm.fluence.dev/-/web/detail/@fluencelabs/avm/v/${{ env.AVM_VERSION }})
To install it run:
```shell
npm login --registry https://npm.fluence.dev
npm i @fluencelabs/avm@${{ env.AVM_VERSION }} --registry=https://npm.fluence.dev
```
publish-interpreter:
name: "Publish air-interpreter-wasm snapshot"
runs-on: ubuntu-latest
needs: wasm
outputs:
version: "${{ steps.build.outputs.version }}"
permissions:
contents: read
pull-requests: write
id-token: write
steps:
- name: Checkout AquaVM
uses: actions/checkout@v3
- name: Download air-interpreter-wasm binary
uses: actions/download-artifact@v3
with:
name: air-interpreter-wasm
- run: mv air_interpreter_server.wasm crates/interpreter-wasm/
- name: Import secrets
uses: hashicorp/vault-action@v2.4.2
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/cargo-registry/users/ci token | CARGO_REGISTRIES_FLUENCE_TOKEN
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install cargo-edit
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-edit
- name: Generate package version
id: version
run: |
SHA=${{ github.event.pull_request.head.sha }}
echo "::set-output name=sha::${SHA::7}"
echo "::set-output name=branch::${GITHUB_HEAD_REF//[^a-zA-Z0-9-]/-}"
- name: Set package version
id: build
env:
BRANCH: ${{ steps.version.outputs.branch }}
SHA: ${{ steps.version.outputs.sha }}
RUN: ${{ github.run_number }}
ATTEMPT: ${{ github.run_attempt }}
working-directory: crates/interpreter-wasm
run: |
cargo set-version --bump alpha
cargo set-version "$(cargo read-manifest | jq -r .version)-${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }}"
echo "::set-output name=version::$(cargo read-manifest | jq -r .version)"
- name: Publish to self-hosted cargo registry
working-directory: crates/interpreter-wasm
run: cargo publish --registry fluence --allow-dirty
- name: Find comment in PR
uses: peter-evans/find-comment@v1
id: comment
with:
issue-number: "${{ github.event.pull_request.number }}"
comment-author: github-actions[bot]
body-includes: "## air-interpreter-wasm version is"
- name: Update comment in PR
uses: peter-evans/create-or-update-comment@v1
env:
VERSION: ${{ steps.build.outputs.version }}
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
edit-mode: replace
body: |
## air-interpreter-wasm version is [${{ env.VERSION }}](https://crates.fluence.dev/#/crate?name=air-interpreter-wasm&version=${{ env.VERSION }})
To install it run:
```shell
cargo add air-interpreter-wasm@${{ env.VERSION }} --registry fluence
```
publish-air-beautify:
name: "Publish air-beautify-wasm snapshot"
runs-on: ubuntu-latest
outputs:
version: "${{ steps.build.outputs.version }}"
permissions:
contents: read
pull-requests: write
id-token: write
steps:
- name: Checkout aquavm
uses: actions/checkout@v3
- name: Import secrets
uses: hashicorp/vault-action@v2.4.2
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
- name: Setup wasm-pack
uses: jetli/wasm-pack-action@v0.3.0
with:
version: 'latest'
- name: Setup node with self-hosted npm registry
uses: actions/setup-node@v3
with:
node-version: "16"
registry-url: "https://npm.fluence.dev"
- name: Build air-beautify-wasm
run: |
rm -rf pack
wasm-pack build --release
working-directory: tools/wasm/air-beautify-wasm
- name: Generate package version
id: version
run: |
SHA=${{ github.event.pull_request.head.sha }}
echo "::set-output name=sha::${SHA::7}"
echo "::set-output name=branch::${GITHUB_HEAD_REF//[^a-zA-Z0-9-]/-}"
- name: Set package version
id: build
env:
BRANCH: ${{ steps.version.outputs.branch }}
SHA: ${{ steps.version.outputs.sha }}
RUN: ${{ github.run_number }}
ATTEMPT: ${{ github.run_attempt }}
working-directory: tools/wasm/air-beautify-wasm/pkg
run: |
echo "::set-output name=version::$(\
npm version prerelease \
--no-git-tag-version \
--preid ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }})"
- name: Publish to self-hosted npm repo
working-directory: tools/wasm/air-beautify-wasm/pkg
run: npm publish --tag snapshot --registry https://npm.fluence.dev
- name: Find comment in PR
uses: peter-evans/find-comment@v1
id: comment
with:
issue-number: "${{ github.event.pull_request.number }}"
comment-author: github-actions[bot]
body-includes: "## air-beautify-wasm version is"
- name: Update comment in PR
uses: peter-evans/create-or-update-comment@v1
env:
AIR_BEAUTIFY_VERSION: ${{ steps.build.outputs.version }}
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
edit-mode: replace
body: |
## air-beautify-wasm version is [${{ env.AIR_BEAUTIFY_VERSION }}](https://npm.fluence.dev/-/web/detail/@fluencelabs/air_beautify/v/${{ env.AIR_BEAUTIFY_VERSION }})
To install it run:
```shell
npm login --registry https://npm.fluence.dev
npm i @fluencelabs/air-beautify-wasm@${{ env.AIR_BEAUTIFY_VERSION }} --registry=https://npm.fluence.dev
```