Publish Release #108
Workflow file for this run
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: Publish Release | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: Release version tag | |
required: true | |
type: string | |
default: 'latest' | |
commit: | |
description: Optional commit to publish from | |
required: false | |
type: string | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
ref: ${{ inputs.commit || github.event.pull_request.head.sha }} | |
- name: Setup node version | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'npm' | |
cache-dependency-path: '**/package-lock.json' | |
- name: Get NPM cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT | |
- name: Restore NPM cache | |
id: npm-cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install node modules | |
run: npm ci | |
- name: Download JSI binding source-code from PR | |
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 | |
with: | |
workflow: pr-realm-js.yml | |
commit: ${{ inputs.commit || github.sha }} | |
path: ${{ github.workspace }} | |
workflow_conclusion: "" # Ignores workflow conclusion | |
github_token: ${{ secrets.REALM_CI_PAT }} | |
name: jsi-binding-source | |
- name: Download TypeScript build from PR | |
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 | |
with: | |
workflow: pr-realm-js.yml | |
commit: ${{ inputs.commit || github.sha }} | |
path: ${{ github.workspace }} | |
workflow_conclusion: "" # Ignores workflow conclusion | |
github_token: ${{ secrets.REALM_CI_PAT }} | |
name: ts-build | |
- name: Download prebuilds from PR | |
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 | |
with: | |
workflow: pr-realm-js.yml | |
commit: ${{ inputs.commit || github.sha }} | |
path: ${{ github.workspace }} | |
workflow_conclusion: "" # Ignores workflow conclusion | |
github_token: ${{ secrets.REALM_CI_PAT }} | |
name: prebuilds | |
- name: Read version | |
id: get-version | |
run: | | |
pkgVersion=$(jq -r .version packages/realm/package.json) | |
echo "version=$pkgVersion" >> $GITHUB_OUTPUT | |
prerelease=false | |
if [ '${{ inputs.tag }}' != latest ]; then prerelease=true; fi | |
echo "prerelease=$prerelease" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Set up S3cmd and configure AWS credentials | |
uses: s3-actions/[email protected] | |
with: | |
provider: aws | |
region: "us-east-1" | |
access_key: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} | |
secret_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} | |
- name: Upload prebuilds to S3 | |
run: s3cmd put --recursive --acl-public packages/realm/prebuilds/realm-* s3://${{ secrets.PREBUILDS_S3_BUCKET_NAME }}/${{ steps.get-version.outputs.version }}/ | |
- name: Publish realm v${{ steps.get-version.outputs.version }} on NPM | |
run: npm publish --provenance --workspace realm --tag '${{ inputs.tag}}' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Find Release PR | |
uses: juliangruber/[email protected] | |
id: find-pull-request | |
with: | |
branch: ${{ github.ref }} | |
- name: Merge Pull Request | |
uses: juliangruber/merge-pull-request-action@8a13f2645ad8b6ada32f829b2fae9c0955a5265d | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
number: ${{ steps.find-pull-request.outputs.number }} | |
method: squash | |
- name: Checkout base branch (after merge) | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
ref: ${{ steps.find-pull-request.outputs.base-ref }} | |
- name: Install node modules (again) | |
run: npm ci | |
- name: Extract Changelog | |
run: node scripts/extract-changelog.js ${{ steps.get-version.outputs.version }} > EXTRACTED_CHANGELOG.md | |
- name: Create Github Release | |
uses: ncipollo/release-action@10c84d509b28aae3903113151bfd832314964f2e | |
with: | |
bodyFile: EXTRACTED_CHANGELOG.md | |
name: Realm JavaScript v${{ steps.get-version.outputs.version }} | |
tag: v${{ steps.get-version.outputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
draft: false | |
prerelease: ${{ steps.get-version.outputs.prerelease }} | |
- name: 'Post to #realm-releases' | |
uses: realm/ci-actions/release-to-slack@9166f8af1cc0739f03702c66294ed2fe4cc55f4c | |
with: | |
changelog: EXTRACTED_CHANGELOG.md | |
sdk: JavaScript | |
webhook-url: ${{ secrets.SLACK_RELEASE_WEBHOOK }} | |
version: ${{ steps.get-version.outputs.version }} | |
# This job might fail due to failed markdown-to-slack conversion. | |
continue-on-error: true | |
- name: Update Changelog | |
run: npm run prepend-changelog-header | |
- name: Create vNext PR | |
id: vnext-pr | |
uses: peter-evans/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad | |
with: | |
branch: prepare-vnext | |
title: Prepare for vNext | |
body: Update Changelog for vNext | |
delete-branch: true | |
commit-message: Prepare for vNext | |
base: ${{ steps.find-pull-request.outputs.base-ref }} | |
labels: no-jira-ticket | |
- name: Merge Pull Request | |
uses: juliangruber/merge-pull-request-action@8a13f2645ad8b6ada32f829b2fae9c0955a5265d | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
number: ${{ steps.vnext-pr.outputs.pull-request-number }} | |
method: squash |