-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a76b6fe
commit 2babd3e
Showing
5 changed files
with
88 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,18 @@ jobs: | |
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get package name for tag | ||
id: tag | ||
run: | | ||
# `%@*` truncates @ and version number from the right side. | ||
# https://stackoverflow.com/questions/9532654/expression-after-last-specific-character | ||
# https://www.edwardthomson.com/blog/github_actions_15_sharing_data_between_steps.html | ||
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-setting-an-output-parameter | ||
pkgName=${GITHUB_REF_NAME%@*} | ||
echo "::set-output name=pkgName::$pkgName" | ||
# `%@*` truncates @ and version number from the right side. | ||
# https://stackoverflow.com/questions/9532654/expression-after-last-specific-character | ||
# https://www.edwardthomson.com/blog/github_actions_15_sharing_data_between_steps.html | ||
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-setting-an-output-parameter | ||
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables | ||
# GITHUB_REF_NAME === The branch or tag name that triggered the workflow run. For example, `@videojs-player/[email protected]`. | ||
# MARK: package dir should not be coupled with package name. `@videojs-player/[email protected]` > `vue` | ||
# - name: Get package name for tag | ||
# id: tag | ||
# run: | | ||
# pkgDirName=${GITHUB_REF_NAME%@*} | ||
# echo "::set-output name=pkgDirName::$pkgDirName" | ||
|
||
- name: Create Release | ||
id: create_release | ||
|
@@ -36,4 +39,4 @@ jobs: | |
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
Please refer to [CHANGELOG.md](https://github.com/surmon-china/videojs-player/blob/${{ github.ref_name }}/packages/${{ steps.tag.outputs.pkgName }}/CHANGELOG.md) for details. | ||
Please refer to [CHANGELOG.md](https://github.com/surmon-china/videojs-player#changelog) for details. |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,39 @@ | ||
// https://github.com/vitejs/vite/blob/main/scripts/publishCI.ts | ||
const { exec, getPackageByName, getPrereleaseTagByVersion } = require('./utils') | ||
|
||
async function main() { | ||
const [tag] = process.argv.slice(2) | ||
if (!tag) { | ||
throw new Error('No tag specified') | ||
} | ||
|
||
console.log(`Publish ${tag}`) | ||
|
||
const [_, _packageName, packageVersion] = tag.split('@') | ||
const packageName = `@${_packageName}` | ||
const package = getPackageByName(packageName) | ||
if (!package) { | ||
throw new Error(`Package "${packageName}" not found.`) | ||
} | ||
|
||
const { dirPath, json } = package | ||
if (packageVersion !== json.version) | ||
throw new Error( | ||
`Package version from tag "${packageVersion}" mismatches with current version "${json.version}"` | ||
) | ||
|
||
console.log('Publishing package...') | ||
|
||
const publicArgs = ['publish', '--access', 'public'] | ||
const releaseTag = getPrereleaseTagByVersion(packageVersion) | ||
if (releaseTag) { | ||
publicArgs.push(`--tag`, releaseTag) | ||
} | ||
|
||
await exec(`cd ${dirPath} && npm ${publicArgs.join(' ')}`) | ||
console.log() | ||
} | ||
|
||
main().catch((err) => { | ||
console.error(err) | ||
process.exit(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
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,27 @@ | ||
const path = require('path') | ||
const fs = require('fs-extra') | ||
const util = require('util') | ||
const exec = util.promisify(require('child_process').exec) | ||
|
||
const rootDirPath = path.join(__dirname, '..') | ||
const packagesDirPath = path.join(rootDirPath, 'packages') | ||
const packages = fs.readdirSync(packagesDirPath).map((dirName) => { | ||
const dirPath = path.join(packagesDirPath, dirName) | ||
const json = require(path.resolve(dirPath, 'package.json')) | ||
return { dirName, dirPath, json } | ||
}) | ||
|
||
exports.exec = exec | ||
exports.packages = packages | ||
|
||
exports.getPackageByName = (packageName) => { | ||
return packages.find((package) => package.json.name === packageName) | ||
} | ||
|
||
exports.getPrereleaseTagByVersion = (packageVersion) => { | ||
return packageVersion.includes('beta') | ||
? 'beta' | ||
: packageVersion.includes('alpha') | ||
? 'alpha' | ||
: void 0 | ||
} |