# This is a basic workflow to help you get started with Actions name: Release # Controls when the action will run. on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: version: # Friendly description to be shown in the UI instead of 'name' description: "Version to release (if the version contains the beta keyword, we assume it is a pre-release)" # Default value if no value is explicitly provided default: "" # Input has to be provided for the workflow to run required: true env: NPM_CONFIG_FETCH_RETRIES: 3 NPM_CONFIG_FETCH_RETRY_FACTOR: 2 NPM_CONFIG_FETCH_RETRY_MINTIMEOUT: 5000 NPM_CONFIG_FETCH_RETRY_MAXTIMEOUT: 20000 jobs: # This workflow contains a single job called "build" build-all: # The type of runner that the job will run on runs-on: ubuntu-22.04 # @link https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs permissions: contents: write # @link https://docs.npmjs.com/generating-provenance-statements#about-npm-provenance id-token: write # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v7 - name: Set prerelease variable id: vars run: | echo ::set-output name=prerelease::${{ contains(github.event.inputs.version, 'beta') }} echo ::set-output name=nonPatchRelease::${{ endsWith(github.event.inputs.version, '.0') }} - name: Log parsed version run: | echo "version: ${{github.event.inputs.version}}" echo "prerelease: ${{ steps.vars.outputs.prerelease }}" - name: Set git config run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" - name: Setup Node.js environment uses: actions/setup-node@v7.0.0 with: node-version-file: ".nvmrc" registry-url: "https://registry.npmjs.org" - name: Reuse npm cache folder uses: actions/cache@v6 env: cache-name: cache-node-modules with: path: | ~/.npm key: ${{ runner.os }}-npm-root-v1-${{ hashFiles('**/package.json', '**/.npmrc') }} restore-keys: | ${{ runner.os }}-npm-root-v1- - name: install npm dependencies run: | node -v rm -rf node_modules/ npm install - name: "update version and changelog" working-directory: "scripts" env: RXDB_SERVER_TOKEN: ${{ secrets.RXDB_SERVER_VERSION_BUMP }} RXDB_PREMIUM_FETCH_CHANGELOG: ${{ secrets.RXDB_PREMIUM_FETCH_CHANGELOG }} run: | node set-version.mjs ${{github.event.inputs.version}} - run: npm run build - run: npm run generate:error-messages - name: build docs if: steps.vars.outputs.prerelease == 'false' run: | (cd docs-src && (npm install)) npm run generate:headers npm run docs:build # - name: "update release workflow default version" # run: | # sed -i 's/^ default: ".*"/ default: "${{github.event.inputs.version}}"/' .github/workflows/release.yml - name: add git tag run: | git add . git status . git diff package.json git commit -m ${{github.event.inputs.version}} git tag ${{github.event.inputs.version}} - run: npm publish --tag next if: steps.vars.outputs.prerelease == 'true' env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm publish --provenance --access public if: steps.vars.outputs.prerelease == 'false' env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # pull again to make it unlikely that we have a merge conflict. - run: git pull - name: Push changes uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} # Software Bill of Materials for the released version. # Lists every runtime dependency with its version, license and integrity # hash. Dev dependencies are omitted because they are not shipped to users. # Both formats are generated because consumers' tooling reads one or the other. - name: generate SBOM run: | npm sbom --sbom-format cyclonedx --sbom-type library --omit dev > rxdb-sbom.cdx.json npm sbom --sbom-format spdx --sbom-type library --omit dev > rxdb-sbom.spdx.json node -e "JSON.parse(require('fs').readFileSync('rxdb-sbom.cdx.json'))" node -e "JSON.parse(require('fs').readFileSync('rxdb-sbom.spdx.json'))" # must run after the push # because it otherwise does not know # about the tag and add the old source code to the release. # This might be a bug. - uses: ncipollo/release-action@v1.21.0 with: prerelease: ${{ steps.vars.outputs.prerelease }} tag: ${{github.event.inputs.version}} bodyFile: "./release-body.md" artifacts: "rxdb-sbom.cdx.json,rxdb-sbom.spdx.json" token: ${{ secrets.GITHUB_TOKEN }} # @link https://github.com/marketplace/actions/actions-for-discord - name: Discord notification # To not spam users too much, we only do this on major and minor releases if: steps.vars.outputs.prerelease == 'false' && steps.vars.outputs.nonPatchRelease == 'true' uses: Ilshidur/action-discord@master env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} with: args: "@everyone A new RxDB version has been released: https://rxdb.info/release/?discord=release&version=${{github.event.inputs.version}}" # @link https://github.com/marketplace/actions/send-tweet-action # - name: Twitter notification # # To not spam users too much, we only do this on major and minor releases # if: steps.vars.outputs.prerelease == 'false' && steps.vars.outputs.nonPatchRelease == 'true' # uses: ethomson/send-tweet-action@v1 # with: # status: "A new #RxDB version ${{github.event.inputs.version}} has been released: https://github.com/pubkey/rxdb/releases/tag/${{github.event.inputs.version}}" # consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }} # consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} # access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} # access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} # Notify rxdb-server to update its rxdb dependency # @link https://github.com/pubkey/rxdb-server/pull/376 - name: Notify rxdb-server of new release run: | curl -X POST https://api.github.com/repos/pubkey/rxdb-server/dispatches \ -H "Authorization: token ${{ secrets.RXDB_SERVER_VERSION_BUMP }}" \ -H "Accept: application/vnd.github.v3+json" \ -d '{"event_type":"rxdb-release"}' - name: notify bing indexnow if: steps.vars.outputs.prerelease == 'false' run: npm run docs:notify-indexnow