Skip to content

Commit

Permalink
Set and use CIRCLE_TAG (#2021)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi authored Jan 9, 2024
1 parent 3148bb1 commit a9e5c8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
19 changes: 12 additions & 7 deletions .ado/templates/apple-job-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ steps:
echo "Set latest to: $LATEST"
condition: eq(variables['Build.SourceBranchName'], variables.latestStableBranch)

- task: CmdLine@2
displayName: Set next package version
inputs:
script: |
echo "Next package version: $RNM_PACKAGE_VERSION"
echo "##vso[task.setvariable variable=RNM_PACKAGE_VERSION]$(node .ado/get-next-semver-version.js)
# Note, This won't do the actual `git tag` and `git push` as we're doing a dry run.
# We do that as a separate step in `.ado/publish.yml`.
- task: CmdLine@2
displayName: Prepare package for release
inputs:
script: |
VERSION=$(node .ado/get-next-semver-version.js)
if [[ -z "$VERSION" ]]; then
VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -1)
echo "Using the version from the package.json: $VERSION"
fi
node ./scripts/prepare-package-for-release.js -v "$VERSION" --dry-run
node ./scripts/prepare-package-for-release.js -v "$RNM_PACKAGE_VERSION" --dry-run
env:
# Map the corresponding variable since `prepare-package-for-release.js` depends on it.
# Map the corresponding CircleCI variable since `prepare-package-for-release.js` depends on it.
CIRCLE_BRANCH: $(Build.SourceBranchName)

# Note: This won't actually publish to NPM as we've commented that bit out.
Expand All @@ -39,3 +41,6 @@ steps:
inputs:
script: |
node ./scripts/publish-npm.js -t ${{ parameters.build_type }}
env:
# Map the corresponding CircleCI variable since `publish-npm.js` depends on it.
CIRCLE_TAG: $(RNM_PACKAGE_VERSION)
19 changes: 1 addition & 18 deletions scripts/npm-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ const {
getCurrentCommit,
isTaggedLatest,
} = require('./scm-utils');
const path = require('path'); // [macOS]
const fs = require('fs'); // [macOS]

// [macOS] Function to get our version from package.json instead of the CircleCI build tag.
function getPkgJsonVersion() {
const RN_PACKAGE_DIRECTORY = path.resolve(
__dirname,
'..',
'packages',
'react-native',
);
const pkgJsonPath = path.resolve(RN_PACKAGE_DIRECTORY, 'package.json');
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
const pkgJsonVersion = pkgJson.version;
return pkgJsonVersion;
}
// macOS]

// Get `next` version from npm and +1 on the minor for `main` version
function getMainVersion() {
Expand Down Expand Up @@ -65,7 +48,7 @@ function getNpmInfo(buildType) {
}

const {version, major, minor, prerelease} = parseVersion(
getPkgJsonVersion(), // [macOS] We can't use the CircleCI build tag, so we use the version argument instead.
process.env.CIRCLE_TAG,
buildType,
);

Expand Down

0 comments on commit a9e5c8e

Please sign in to comment.