-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create releases where PATCH doesn't have to match react-native (#…
…43) This feature needs to be released with react-native-community/cli#2475, which decouples the 1:1 release model we have for templates and react-native. Switching users to this is going to be difficult, and should only be rolled asap before 0.76. If we have to release a template fix, then only users with the latest CLI will be able to use that and subsequent versions. I'm not sure of how to clearly communicate that to users. - Added tests - Set dry_run to default
- Loading branch information
Showing
6 changed files
with
2,244 additions
and
15 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('jest').Config} */ | ||
const config = { | ||
coverageProvider: "v8", | ||
testMatch: [ | ||
"**/__tests__/*.js", | ||
], | ||
}; | ||
|
||
module.exports = config; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const {execSync} = require('child_process'); | ||
const semver = require('semver'); | ||
|
||
function run(version) { | ||
return execSync(`./bumpedTemplateVersion.sh ${version}`, { cwd: 'scripts', stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim(); | ||
} | ||
|
||
describe('bumpTemplateVersion.sh', () => { | ||
|
||
it('nightlies stay the same', () => { | ||
expect(run('0.75.0-nightly-20240606-4324f0874')).toEqual('0.75.0-nightly-20240606-4324f0874'); | ||
}); | ||
|
||
it('release candidates appended with a sha', () => { | ||
expect(run('0.74.0-rc.3')).toMatch(/0\.74\.0-rc\.3-.+/); | ||
}); | ||
|
||
it('assumed it is the first version when no matching MAJOR.MINOR', () => { | ||
const versionShouldNeverExist = '1111.0.1'; | ||
expect(run(versionShouldNeverExist)).toEqual('1111.0.0'); | ||
}); | ||
|
||
it('bumps the patch if a version of the template already exists', async () => { | ||
// This sucks I know: | ||
const {version} = await fetch('https://registry.npmjs.com/@react-native-community/template/latest').then(resp => resp.json()); | ||
const {major, minor, patch} = semver.parse(version); | ||
expect(run(`${major}.${minor}.${patch}`)).toEqual(`${major}.${minor}.${patch+1}`); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# What this does: | ||
# 1. Take the version of react, use the MAJOR.MINOR | ||
# - /nightly/ -> MAJOR.MINOR.PATCH-nightly-YYYYNN-HASH | ||
# - /-rc.N/ -> MAJOR.MINOR.PATCH-rc.N-HASH | ||
# - ELSE: continue | ||
# 2. Look for the latest version of the template with that MAJOR.MINOR | ||
# - No version -> then set to MAJOR.MINOR.0 | ||
# - MAJOR.MINOR.PATCH -> MAJOR.MINOR.PATCH+1 | ||
|
||
log() { | ||
echo "$@" >&2 | ||
} | ||
|
||
if [[ $# != 1 ]]; then | ||
log "USAGE: bumpTemplateVersion.sh <react native version>" | ||
exit 1 | ||
fi | ||
|
||
if [[ $1 =~ -rc\.[0-9]+ ]]; then | ||
log "Release candidate" | ||
# Append a sha, so if we need to re-release for a RC we don't conflict | ||
echo $1-$(git rev-parse --short HEAD) | ||
exit 0 | ||
fi | ||
|
||
if [[ $1 =~ -nightly- ]]; then | ||
log "Nightly candidate" | ||
# Once a day, we're not going to get conflicts using the given nightly tag | ||
echo $1 | ||
exit 0 | ||
fi | ||
|
||
# Find current version of template that matches this version of react-native. | ||
if [[ $1 =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
MAJOR_MINOR=$(awk -F'.' '{ print $1"."$2 }' <<< $1) | ||
CURRENT_VERSION=$(npm show --json "@react-native-community/template@^$MAJOR_MINOR") | ||
if [ $? -ne 0 ]; then | ||
echo "$MAJOR_MINOR.0"; | ||
exit 0; | ||
fi | ||
# Bump PATCH | ||
PUBLISHED=$(jq -r 'last | .version' <<< $CURRENT_VERSION | awk -F'.' '{ print $1"."$2"."($3+1) }') | ||
echo $PUBLISHED; | ||
exit 0 | ||
fi | ||
|
||
log "Unknown type of release: $RN_VERSION" | ||
exit 1 |
Oops, something went wrong.