-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* npm-publish workflow * Update .github/workflows/npm-publish.yml * improvements * publish on tags * removed deprecated command * Rewrited npm-publish action * added support for different versions * removed redundant func since it doesn't affect logic * removed auto commit * updated packages.json for npm publish --------- Co-authored-by: Andriy Lysnevych <[email protected]>
- Loading branch information
1 parent
26361e4
commit f37eae0
Showing
5 changed files
with
154 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
setup_and_build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
registry-url: "https://registry.npmjs.org/" | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v3 | ||
with: | ||
version: 8 | ||
|
||
- name: Install Dependencies | ||
run: pnpm install | ||
|
||
- name: Extract version from tag | ||
id: get_version | ||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
|
||
- name: Update package.json version | ||
run: | | ||
export TAG=$VERSION | ||
node update-versions.js | ||
working-directory: ./scripts | ||
|
||
- name: Build | ||
run: pnpm run build | ||
|
||
- name: Pack Packages | ||
run: pnpm run pack-packages | ||
|
||
- name: NPM Publish Packages | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
for package in p2p-media-loader-core p2p-media-loader-hlsjs p2p-media-loader-shaka; do | ||
pnpm publish ./packages/$package/$package-$VERSION.tgz --access public | ||
done |
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
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,35 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const packages = [ | ||
"../packages/p2p-media-loader-core/package.json", | ||
"../packages/p2p-media-loader-hlsjs/package.json", | ||
"../packages/p2p-media-loader-shaka/package.json", | ||
]; | ||
|
||
function updateVersion(packagePath, newVersion) { | ||
const fullPath = path.resolve(packagePath); | ||
const packageJson = require(fullPath); | ||
const updatedPackageJson = { ...packageJson, version: newVersion }; | ||
fs.writeFileSync( | ||
fullPath, | ||
JSON.stringify(updatedPackageJson, null, 2) + "\n", | ||
); | ||
} | ||
|
||
function main() { | ||
const newVersion = process.env.TAG; | ||
if (!newVersion) { | ||
console.error( | ||
"ERROR: No version provided. Please set the TAG environment variable.", | ||
); | ||
process.exit(1); | ||
} | ||
|
||
packages.forEach((packagePath) => { | ||
updateVersion(packagePath, newVersion); | ||
console.log(`Updated ${packagePath} to version ${newVersion}`); | ||
}); | ||
} | ||
|
||
main(); |