fluence-js/.github/workflows/snapshot.yml

114 lines
3.5 KiB
YAML
Raw Normal View History

name: Publish snapshot
on:
workflow_call:
inputs:
avm-version:
description: "@fluencelabs/avm version"
type: string
outputs:
fluence-js-version:
description: "@fluencelabs/fluence version"
value: ${{ jobs.publish-snapshot.outputs.fluence-js-version }}
env:
FORCE_COLOR: true
CI: true
jobs:
publish-snapshot:
name: "Publish snapshot"
runs-on: ubuntu-latest
outputs:
fluence-js-version: "${{ steps.build.outputs.version }}"
permissions:
contents: read
pull-requests: write
id-token: write
steps:
- name: Checkout fluence-js
uses: actions/checkout@v3
with:
repository: fluencelabs/fluence-js
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: Setup node with self-hosted npm registry
uses: actions/setup-node@v3
with:
node-version: "16"
registry-url: "https://npm.fluence.dev"
cache: "pnpm"
- run: pnpm i
- name: Set avm version from branch
if: inputs.avm-version != ''
working-directory: packages/fluence-js
run: pnpm add --save -E @fluencelabs/avm@${{ inputs.avm-version }}
- run: pnpm -r build
- 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: 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 }}
run: |
node ci.js bump-version ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }}
echo "::set-output name=version::$(node ci.js get-version)"
- name: Publish to self-hosted npm repo
run: pnpm --no-git-checks --registry https://npm.fluence.dev -r publish --tag e2e -filter '@fluencelabs/*'
- 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: "## FluenceJS version is"
- name: Update comment in PR
uses: peter-evans/create-or-update-comment@v1
env:
FLUENCE_JS_VERSION: ${{ steps.build.outputs.version }}
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
edit-mode: replace
body: |
## FluenceJS version is [${{ env.FLUENCE_JS_VERSION }}](https://npm.fluence.dev/-/web/detail/@fluencelabs/fluence/v/${{ env.FLUENCE_JS_VERSION }})
To install it run:
```shell
npm login --registry https://npm.fluence.dev
npm i -E @fluencelabs/fluence@${{ env.FLUENCE_JS_VERSION }} --registry=https://npm.fluence.dev
```