mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
a52f5514ed
Summary: One of the steps we perform when doing a release is to run `npm view react-native` to verify that the release has been published and it is available with the right tag. As of today, we check this manually. This change aims at automating this check so that we don't have to do it manually ourselves. ## Changelog: [Internal] - Releases: automate the npm view check Pull Request resolved: https://github.com/facebook/react-native/pull/49164 Test Plan: Created a veriftyReleaseOnNPM-tests.js jest test to verify that the script works fine. <img width="667" alt="Screenshot 2025-02-04 at 15 18 24" src="https://github.com/user-attachments/assets/cf08155f-80da-4e15-a922-5c16f3fd806e" /> Reviewed By: cortinico Differential Revision: D69118622 Pulled By: cipolleschi fbshipit-source-id: a8d40cd2fcb164d8f7174de680b340510f3e8551
227 lines
8.9 KiB
YAML
227 lines
8.9 KiB
YAML
name: Publish Release
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v0.*.*" # This should match v0.X.Y
|
|
- "v0.*.*-rc.*" # This should match v0.X.Y-RC.0
|
|
jobs:
|
|
set_release_type:
|
|
runs-on: ubuntu-latest
|
|
if: github.repository == 'facebook/react-native'
|
|
outputs:
|
|
RELEASE_TYPE: ${{ steps.set_release_type.outputs.RELEASE_TYPE }}
|
|
env:
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
REF: ${{ github.ref }}
|
|
steps:
|
|
- id: set_release_type
|
|
run: |
|
|
echo "Setting release type to release"
|
|
echo "RELEASE_TYPE=release" >> $GITHUB_OUTPUT
|
|
|
|
prepare_hermes_workspace:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
HERMES_WS_DIR: /tmp/hermes
|
|
HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion
|
|
outputs:
|
|
react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }}
|
|
hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Prepare Hermes Workspace
|
|
id: prepare-hermes-workspace
|
|
uses: ./.github/actions/prepare-hermes-workspace
|
|
with:
|
|
hermes-ws-dir: ${{ env.HERMES_WS_DIR }}
|
|
hermes-version-file: ${{ env.HERMES_VERSION_FILE }}
|
|
|
|
build_hermesc_apple:
|
|
runs-on: macos-13
|
|
needs: prepare_hermes_workspace
|
|
env:
|
|
HERMES_WS_DIR: /tmp/hermes
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Build HermesC Apple
|
|
uses: ./.github/actions/build-hermesc-apple
|
|
with:
|
|
hermes-version: ${{ needs.prepare_hermes_workspace.output.hermes-version }}
|
|
react-native-version: ${{ needs.prepare_hermes_workspace.output.react-native-version }}
|
|
build_apple_slices_hermes:
|
|
runs-on: macos-14
|
|
needs: [build_hermesc_apple, prepare_hermes_workspace]
|
|
env:
|
|
HERMES_WS_DIR: /tmp/hermes
|
|
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
|
|
HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin
|
|
IOS_DEPLOYMENT_TARGET: "15.1"
|
|
XROS_DEPLOYMENT_TARGET: "1.0"
|
|
MAC_DEPLOYMENT_TARGET: "10.15"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
flavor: [Debug, Release]
|
|
slice: [macosx, iphoneos, iphonesimulator, appletvos, appletvsimulator, catalyst, xros, xrsimulator]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Build Slice
|
|
uses: ./.github/actions/build-apple-slices-hermes
|
|
with:
|
|
flavor: ${{ matrix.flavor }}
|
|
slice: ${{ matrix.slice}}
|
|
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
|
|
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
|
|
|
|
build_hermes_macos:
|
|
runs-on: macos-13
|
|
needs: [build_apple_slices_hermes, prepare_hermes_workspace]
|
|
env:
|
|
HERMES_WS_DIR: /tmp/hermes
|
|
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
|
|
continue-on-error: true
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
flavor: [Debug, Release]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Build Hermes MacOS
|
|
uses: ./.github/actions/build-hermes-macos
|
|
with:
|
|
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
|
|
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
|
|
flavor: ${{ matrix.flavor }}
|
|
|
|
build_hermesc_linux:
|
|
runs-on: ubuntu-latest
|
|
needs: prepare_hermes_workspace
|
|
env:
|
|
HERMES_WS_DIR: /tmp/hermes
|
|
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Build HermesC Linux
|
|
uses: ./.github/actions/build-hermesc-linux
|
|
with:
|
|
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
|
|
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
|
|
|
|
build_hermesc_windows:
|
|
runs-on: windows-2019
|
|
needs: prepare_hermes_workspace
|
|
env:
|
|
HERMES_WS_DIR: 'D:\tmp\hermes'
|
|
HERMES_TARBALL_ARTIFACTS_DIR: 'D:\tmp\hermes\hermes-runtime-darwin'
|
|
HERMES_OSXBIN_ARTIFACTS_DIR: 'D:\tmp\hermes\osx-bin'
|
|
ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip"
|
|
MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'
|
|
CMAKE_DIR: 'C:\Program Files\CMake\bin'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Build HermesC Windows
|
|
uses: ./.github/actions/build-hermesc-windows
|
|
with:
|
|
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
|
|
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
|
|
|
|
build_android:
|
|
runs-on: 8-core-ubuntu
|
|
needs: [set_release_type]
|
|
container:
|
|
image: reactnativecommunity/react-native-android:latest
|
|
env:
|
|
TERM: "dumb"
|
|
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
|
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
|
|
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
|
|
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
|
|
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Build Android
|
|
uses: ./.github/actions/build-android
|
|
with:
|
|
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
|
|
|
|
build_npm_package:
|
|
runs-on: 8-core-ubuntu
|
|
needs:
|
|
[
|
|
set_release_type,
|
|
prepare_hermes_workspace,
|
|
build_hermes_macos,
|
|
build_hermesc_linux,
|
|
build_hermesc_windows,
|
|
build_android,
|
|
]
|
|
container:
|
|
image: reactnativecommunity/react-native-android:latest
|
|
env:
|
|
TERM: "dumb"
|
|
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
|
# By default we only build ARM64 to save time/resources. For release/nightlies, we override this value to build all archs.
|
|
ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a"
|
|
env:
|
|
HERMES_WS_DIR: /tmp/hermes
|
|
GHA_NPM_TOKEN: ${{ secrets.GHA_NPM_TOKEN }}
|
|
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
|
|
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
|
|
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
|
|
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
|
|
REACT_NATIVE_BOT_GITHUB_TOKEN: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
- name: Build and Publish NPM PAckage
|
|
uses: ./.github/actions/build-npm-package
|
|
with:
|
|
hermes-ws-dir: ${{ env.HERMES_WS_DIR }}
|
|
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
|
|
gha-npm-token: ${{ env.GHA_NPM_TOKEN }}
|
|
- name: Publish @react-native-community/template
|
|
id: publish-template-to-npm
|
|
uses: actions/github-script@v6
|
|
with:
|
|
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
|
|
script: |
|
|
const {publishTemplate} = require('./.github/workflow-scripts/publishTemplate.js')
|
|
const version = "${{ github.ref_name }}"
|
|
const isDryRun = false
|
|
await publishTemplate(github, version, isDryRun);
|
|
- name: Wait for template to be published
|
|
timeout-minutes: 3
|
|
uses: actions/github-script@v6
|
|
with:
|
|
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
|
|
script: |
|
|
const {verifyPublishedTemplate, isLatest} = require('./.github/workflow-scripts/publishTemplate.js')
|
|
const version = "${{ github.ref_name }}"
|
|
await verifyPublishedTemplate(version, isLatest());
|
|
- name: Update rn-diff-purge to generate upgrade-support diff
|
|
run: |
|
|
curl -X POST https://api.github.com/repos/react-native-community/rn-diff-purge/dispatches \
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
-H "Authorization: Bearer $REACT_NATIVE_BOT_GITHUB_TOKEN" \
|
|
-d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"${{ github.ref_name }}\" }}"
|
|
- name: Verify Release is on NPM
|
|
timeout-minutes: 3
|
|
uses: actions/github-script@v6
|
|
with:
|
|
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
|
|
script: |
|
|
const {verifyReleaseOnNpm} = require('./.github/workflow-scripts/verifyReleaseOnNpm.js');
|
|
const {isLatest()} = require('./.github/workflow-scripts/publishTemplate.js');
|
|
const version = "${{ github.ref_name }}";
|
|
await verifyReleaseOnNpm(version, isLatest());
|