Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ado/jobs/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- ${{ if endsWith(parameters.buildEnvironment, 'PullRequest') }}:
- script: npx beachball check --branch origin/$(BeachBallBranchName) --verbose --changehint "##vso[task.logissue type=error]Run \"yarn change\" from root of repo to generate a change file."
displayName: Check for change files
condition: not(startsWith(variables['System.PullRequest.SourceBranch'], 'refs/heads/prepare-release/'))

- script: npx beachball bump --branch origin/$(BeachBallBranchName) --yes --verbose
displayName: beachball bump
Expand Down
48 changes: 48 additions & 0 deletions .ado/prepare-release-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: $(Date:yyyyMMdd).$(Rev:r)

trigger: none
pr: none

schedules:
- cron: "0 */4 * * *"
displayName: Prepare release
branches:
include:
- main
- "*-stable"
always: true

parameters:
- name: AgentPool
type: object
default:
Small:
name: rnw-pool-2-microsoft
demands: ImageOverride -equals rnw-img-vs2022-node22

variables:
- template: variables/windows.yml
- group: RNW Secrets

jobs:
- job: PrepareRelease
displayName: Prepare Release Bot
pool: ${{ parameters.AgentPool.Small }}
timeoutInMinutes: 30

steps:
- template: templates/checkout-full.yml
parameters:
persistCredentials: true

- script: |
git config user.name "React-Native-Windows Bot"
git config user.email "53619745+rnbot@users.noreply.github.com"
displayName: Configure Git Identity

- template: templates/prepare-js-env.yml

- script: npx prepare-release --branch $(Build.SourceBranchName) --no-color
displayName: Prepare Release
env:
GH_TOKEN: $(githubAuthToken)
79 changes: 4 additions & 75 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
name: 0.0.$(Date:yyMM.d)$(Rev:rrr)

parameters:
- name: skipNpmPublish
displayName: Skip Npm Publish
type: boolean
default: false
- name: skipGitPush
displayName: Skip Git Push
type: boolean
default: false
- name: stopOnNoCI
displayName: Stop if latest commit is ***NO_CI***
type: boolean
default: true
- name: performBeachballCheck
displayName: Perform Beachball Check (Disable when promoting)
type: boolean
Expand Down Expand Up @@ -74,14 +62,10 @@ parameters:
variables:
- template: variables/windows.yml
- group: RNW Secrets
- name: SkipGitPushPublishArgs
value: ''
- name: FailCGOnAlert
value: false
- name: EnableCodesign
value: false
- name: SourceBranchWithFolders
value: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]

trigger: none
pr: none
Expand Down Expand Up @@ -112,20 +96,9 @@ extends:
timeoutInMinutes: 120
cancelTimeoutInMinutes: 5
steps:
- powershell: |
Write-Host "Stopping because commit message contains ***NO_CI***."
$uri = "https://dev.azure.com/microsoft/ReactNative/_apis/build/builds/$(Build.BuildId)?api-version=5.1"
$json = @{status="Cancelling"} | ConvertTo-Json -Compress
$build = Invoke-RestMethod -Uri $uri -Method Patch -Headers @{Authorization = "Bearer $(System.AccessToken)"} -ContentType "application/json" -Body $json
Write-Host $build
Write-Host "Waiting 60 seconds for build cancellation..."
Start-Sleep -Seconds 60
displayName: Stop pipeline if latest commit message contains ***NO_CI***
condition: and(${{ parameters.stopOnNoCI }}, contains(variables['Build.SourceVersionMessage'], '***NO_CI***'))

- template: .ado/templates/checkout-full.yml@self
parameters:
persistCredentials: false # We're going to use rnbot's git creds to publish
persistCredentials: false

- powershell: gci env:/BUILD_*
displayName: Show build information
Expand All @@ -146,7 +119,7 @@ extends:
condition: ${{ parameters.performBeachballCheck }}

- job: RnwNpmPublish
displayName: React-Native-Windows Npm Build Rev Publish
displayName: React-Native-Windows Npm Pack
dependsOn: RnwPublishPrep
pool:
name: Azure-Pipelines-1ESPT-ExDShared
Expand All @@ -159,63 +132,19 @@ extends:
parameters:
agentImage: HostedImage

- template: .ado/templates/configure-git.yml@self

- pwsh: |
Write-Host "##vso[task.setvariable variable=SkipGitPushPublishArgs]--no-push"
displayName: Enable No-Publish (git)
condition: ${{ parameters.skipGitPush }}

# Beachball publishes NPM packages to the "$(Pipeline.Workspace)\published-packages" folder.
# It pushes NPM version updates to Git depending on the SkipGitPushPublishArgs variable derived from the skipGitPush parameter.
- script: |
if exist "$(Pipeline.Workspace)\published-packages" rd /s /q "$(Pipeline.Workspace)\published-packages"
mkdir "$(Pipeline.Workspace)\published-packages"
npx beachball publish --no-publish $(SkipGitPushPublishArgs) --pack-to-path "$(Pipeline.Workspace)\published-packages" --branch origin/$(SourceBranchWithFolders) -yes --bump-deps --verbose --access public --message "applying package updates ***NO_CI***"
displayName: Beachball Publish
- script: node .ado/scripts/npmPack.js --clean --no-color "$(Pipeline.Workspace)\published-packages"
displayName: Pack npm packages

- script: dir /s "$(Pipeline.Workspace)\published-packages"
displayName: Show created npm packages

# Beachball reverts to local state after publish, but we want the updates it added
- script: git pull origin $(SourceBranchWithFolders)
displayName: git pull

- script: npx @rnw-scripts/create-github-releases --yes --authToken $(githubAuthToken)
displayName: Create GitHub Releases (New Canary Version)
condition: and(succeeded(), ${{ not(parameters.skipGitPush) }}, ${{ eq(variables['Build.SourceBranchName'], 'main') }} )

- script: npx --yes @rnw-scripts/create-github-releases@latest --yes --authToken $(githubAuthToken)
displayName: Create GitHub Releases (New Stable Version)
condition: and(succeeded(), ${{ not(parameters.skipGitPush) }}, ${{ ne(variables['Build.SourceBranchName'], 'main') }} )

- template: .ado/templates/set-version-vars.yml@self
parameters:
buildEnvironment: Continuous

- script: echo NpmDistTag is $(NpmDistTag)
displayName: Show NPM dist tag

- script: dir /s "$(Pipeline.Workspace)\published-packages"
displayName: Show npm packages before ESRP release

- task: 'SFP.release-tasks.custom-build-release-task.EsrpRelease@10'
displayName: 'ESRP Release to npmjs.com'
condition: and(succeeded(), ne(variables['NpmDistTag'], ''))
inputs:
connectedservicename: 'ESRP-CodeSigning-OGX-JSHost-RNW'
usemanagedidentity: false
keyvaultname: 'OGX-JSHost-KV'
authcertname: 'OGX-JSHost-Auth4'
signcertname: 'OGX-JSHost-Sign3'
clientid: '0a35e01f-eadf-420a-a2bf-def002ba898d'
domaintenantid: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
contenttype: npm
folderlocation: '$(Pipeline.Workspace)\published-packages'
productstate: '$(NpmDistTag)'
owners: 'vmorozov@microsoft.com'
approvers: 'khosany@microsoft.com'

- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 📒 Generate Manifest Npm
inputs:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@rnw-scripts/format-files": "*",
"@rnw-scripts/integrate-rn": "*",
"@rnw-scripts/just-task": "*",
"@rnw-scripts/prepare-release": "*",
"@rnw-scripts/promote-release": "*",
"@rnw-scripts/stamp-version": "0.0.0",
"@rnw-scripts/take-screenshot": "*",
Expand Down
4 changes: 4 additions & 0 deletions packages/@rnw-scripts/prepare-release/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@rnw-scripts'],
parserOptions: {tsconfigRootDir : __dirname},
};
2 changes: 2 additions & 0 deletions packages/@rnw-scripts/prepare-release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/
lib-commonjs/
11 changes: 11 additions & 0 deletions packages/@rnw-scripts/prepare-release/bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node

/**
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* @format
*/

require('source-map-support').install();
require('./lib-commonjs/prepareRelease');
45 changes: 45 additions & 0 deletions packages/@rnw-scripts/prepare-release/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@rnw-scripts/prepare-release",
"version": "0.0.1",
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/react-native-windows",
"directory": "packages/@rnw-scripts/prepare-release"
},
"scripts": {
"build": "rnw-scripts build",
"clean": "rnw-scripts clean",
"lint": "rnw-scripts lint",
"lint:fix": "rnw-scripts lint:fix",
"watch": "rnw-scripts watch"
},
"main": "lib-commonjs/prepareRelease.js",
"bin": {
"prepare-release": "./bin.js"
},
"dependencies": {
"@react-native-windows/find-repo-root": "^0.0.0-canary.99",
"@react-native-windows/package-utils": "^0.0.0-canary.96",
"source-map-support": "^0.5.19"
},
"devDependencies": {
"@rnw-scripts/eslint-config": "1.2.38",
"@rnw-scripts/just-task": "2.3.58",
"@rnw-scripts/ts-config": "2.0.6",
"@types/node": "^22.14.0",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint": "^8.19.0",
"prettier": "2.8.8",
"typescript": "5.0.4"
},
"files": [
"bin.js",
"lib-commonjs"
],
"engines": {
"node": ">= 22"
}
}
49 changes: 49 additions & 0 deletions packages/@rnw-scripts/prepare-release/src/beachballBump.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Beachball change file detection and version bump invocation.
*
* @format
*/

import fs from 'fs';
import path from 'path';

import {exec} from './proc';

/**
* Check whether there are pending beachball change files in the repo.
*
* Beachball stores change files as JSON in the `change/` directory at the
* repo root. If there are any .json files there, there are pending changes.
*/
export function hasChangeFiles(repoRoot: string): boolean {
const changeDir = path.join(repoRoot, 'change');
if (!fs.existsSync(changeDir)) {
return false;
}

const entries = fs.readdirSync(changeDir);
return entries.some(entry => entry.endsWith('.json'));
}

/**
* Run beachball bump to consume change files and update versions/changelogs.
*
* Invokes: npx beachball bump --branch <remote>/<target> --yes --verbose
*
* The --yes flag suppresses prompts.
* The --verbose flag provides detailed output.
* The --branch flag tells beachball the baseline branch to diff against.
*/
export async function bumpVersions(opts: {
targetBranch: string;
remote: string;
cwd: string;
}): Promise<void> {
await exec(
`npx beachball bump --branch ${opts.remote}/${opts.targetBranch} --yes --verbose`,
{cwd: opts.cwd},
);
}
Loading
Loading