Skip to content

Commit

Permalink
RUN-1659: Add release workflows
Browse files Browse the repository at this point in the history
- Use release-drafter to draft releases on pushes to main similar to
  marketplace
- On release publish, update the version in package.json and publish
  to github packages
- Don't run tests on main (redundant)
- Update .npmrc to use rvshare's github packages registry
- Sneak in a `Promise.isRejected` polyfill allowlist item
- Update URLS in package.json and remove `prepare`
  • Loading branch information
MinaKemp committed Dec 18, 2024
1 parent 9a35248 commit 9b95a7d
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name-template: "v$NEXT_PATCH_VERSION 🎉"
tag-template: "v$NEXT_PATCH_VERSION"
change-template: "* $TITLE (#$NUMBER) @$AUTHOR"
template: |
## Changes
$CHANGES
## Contributors
$CONTRIBUTORS
16 changes: 16 additions & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Draft Release

on:
push:
branches:
- main

jobs:
update-draft-release:
if: !startsWith(github.event.head_commit.message, '[no-release-draft]')
runs-on: ubuntu-latest

steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Release

on:
release:
types: [published]

jobs:
publish-release:
name: Publish release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Build the project
run: npm run build

- name: Configure git
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
- name: Update package.json version
run: |
# get version from tag and update package.json
VERSION=${GITHUB_REF#refs/tags/}
echo "Setting version in package.json to ${VERSION}"
npm version ${VERSION} --no-git-tag-version
# push to main
git add package.json
git commit -m "[no-release-draft] Update package.json to version ${VERSION}"
git push origin main
# move tag to HEAD
git push --force origin "HEAD:refs/tags/${VERSION}"
git fetch --tags
- name: Publish to Github Packages
run: npm publish

5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Run tests

on: [push]
on:
push:
branches-ignore:
- main # This branch can only be pushed to via PRs, which would have run tests already

jobs:
test:
Expand Down
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
package-lock=false
audit-level=critical

@rvshare:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "A service for server-side rendering your JavaScript views",
"main": "lib/index.js",
"scripts": {
"prepare": "npm run build",
"clean": "rimraf lib",
"prebuild": "npm run clean",
"build": "babel src -d lib",
Expand All @@ -20,7 +19,7 @@
},
"repository": {
"type": "git",
"url": "git@github.com:airbnb/hypernova.git"
"url": "git@github.com:rvshare/hypernova.git"
},
"keywords": [
"react",
Expand All @@ -41,9 +40,9 @@
],
"license": "MIT",
"bugs": {
"url": "https://github.com/airbnb/hypernova/issues"
"url": "https://github.com/rvshare/hypernova/issues"
},
"homepage": "https://github.com/airbnb/hypernova",
"homepage": "https://github.com/rvshare/hypernova",
"devDependencies": {
"@babel/cli": "^7.25.9",
"@babel/core": "^7.26.0",
Expand Down
2 changes: 1 addition & 1 deletion src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const promiseShimsEnvKey = 'HYPERNOVA_PROMISE_SHIMS';
const shouldShimPromise = envIsTrue(process.env[promiseShimsEnvKey]);

const es6methods = ['then', 'catch', 'constructor', 'finally'];
const es6StaticMethods = ['all', 'allSettled', 'any', 'race', 'resolve', 'reject', 'cast', 'try', 'withResolvers'];
const es6StaticMethods = ['all', 'allSettled', 'any', 'race', 'resolve', 'reject', 'cast', 'try', 'withResolvers', 'isRejected'];

function isNotMethod(name) {
return !(es6methods.includes(name) || es6StaticMethods.includes(name) || name.charAt(0) === '_');
Expand Down

0 comments on commit 9b95a7d

Please sign in to comment.