-
-
Notifications
You must be signed in to change notification settings - Fork 5k
feat: add automated published branch releases for dev & main #10520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
47a0b15
feat: add beta release workflow
danielbarion dff62c1
chore: rename beta release message from react-tooltip to pixi.js
danielbarion 47bf56d
chore: refactor auto beta release to be publish branch
danielbarion ef0e179
chore: use npm cache instead of yarn cache
danielbarion 35d3f28
chore: refactor publish-branch.yaml to use shared setup
danielbarion 27ed73e
Update .github/workflows/publish-branch.yaml
danielbarion 2284b29
chore: refactor publish-branch workflow to handle the full workflow
danielbarion 40fb0ad
chore: remove unecessary line from publish-branch workflow
danielbarion af8f8dc
chore: remove minimist package as it is not necessary anymore
danielbarion dd90cc0
chore: remove npmrc setup from publish branch workflow
danielbarion 5ae501c
chore: add npm run build into the publish workflow
danielbarion 1e79e21
Merge branch 'dev' into feat/automated-beta-releases
danielbarion a194cab
Merge branch 'dev' into feat/automated-beta-releases
danielbarion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,77 @@ | ||
| name: Publish Branch | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - dev | ||
|
|
||
| jobs: | ||
| release_candidate: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.head_ref }} | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "16.x" | ||
| registry-url: "https://registry.npmjs.org" | ||
| cache: "yarn" | ||
|
danielbarion marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Install dev dependencies | ||
| run: yarn install | ||
|
bigtimebuddy marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Setup npm credentials file | ||
| run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> .npmrc | ||
|
danielbarion marked this conversation as resolved.
Outdated
|
||
|
|
||
| # - name: Setup git credentials | ||
| # run: | | ||
| # git config --global user.name 'Auto Release Bot' | ||
| # git config --global user.email 'auto-release-bot@users.noreply.github.com' | ||
|
|
||
| - name: Get current package.json version | ||
| run: echo "PACKAGE_VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_ENV | ||
|
|
||
| # get the sort SHA and add it into the environment variables | ||
| - name: Get short SHA | ||
| run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV | ||
|
|
||
| # get the package name so the workflow can be reusable between projects | ||
| # - name: Get current package.json name | ||
| # run: echo "PACKAGE_NAME=$(npm pkg get name | tr -d '"')" >> $GITHUB_ENV | ||
|
|
||
| - name: Setup Branch Release Candidate Version | ||
| run: echo "NEW_VERSION=$PACKAGE_VERSION-$BRANCH_NAME.$SHORT_SHA" >> $GITHUB_ENV | ||
|
|
||
| - name: Update Package.json Version with Release Candidate Version | ||
| run: node ./update-branch-version.js --version $NEW_VERSION | ||
|
danielbarion marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Publish a new branch release candidate version | ||
| run: npm publish --tag $BRANCH_NAME | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
danielbarion marked this conversation as resolved.
Outdated
|
||
|
|
||
| # This comment only works for Pull Requests | ||
| # - uses: actions/github-script@v6 | ||
| # with: | ||
| # script: | | ||
| # github.rest.issues.createComment({ | ||
| # issue_number: context.issue.number, | ||
| # owner: context.repo.owner, | ||
| # repo: context.repo.repo, | ||
| # body: `Release candidate released with the last commit 🚀 | ||
|
|
||
| # \`\`\` | ||
| # yarn add ${{ env.PACKAGE_NAME}}@${{ env.NEW_VERSION }} | ||
| # \`\`\` | ||
| # or | ||
| # \`\`\` | ||
| # npm install ${{ env.PACKAGE_NAME}}@${{ env.NEW_VERSION }} | ||
| # \`\`\` | ||
| # ` | ||
| # }) | ||
|
bigtimebuddy marked this conversation as resolved.
Outdated
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,37 @@ | ||
| /* eslint-disable prefer-destructuring */ | ||
| /* eslint-disable @typescript-eslint/no-var-requires */ | ||
| const util = require("util"); | ||
| const exec = util.promisify(require("child_process").exec); | ||
| const args = require("minimist")(process.argv.slice(2)); | ||
|
|
||
| const version = args["version"]; | ||
|
|
||
| console.log("version: ", version); | ||
|
|
||
| const runCommand = async (command) => { | ||
| return new Promise((resolve) => { | ||
| exec(command, (error, stdout, stderr) => { | ||
| resolve({ error, stdout, stderr }); | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| /** | ||
| * @NOTE: This can't be done by only using the workflow, because when we try to update | ||
| * the version to the desired version, we get an error about wrong version format, | ||
| * but directly on CI it works as expected. | ||
| */ | ||
| const UpdateBranchVersion = async () => { | ||
| // update the release candidate version on package.json | ||
| const { error } = await runCommand(`npm version ${version}`); | ||
|
danielbarion marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (error) { | ||
| console.error(error); | ||
| return; | ||
| } | ||
|
|
||
| // the release candidate version is already updated on package.json on the next line | ||
| console.log("Next Release Candidate version: ", `${version}`); | ||
| }; | ||
|
|
||
| UpdateBranchVersion(); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.