-
Notifications
You must be signed in to change notification settings - Fork 211
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
30be1e2
commit 9775cf3
Showing
7 changed files
with
2,373 additions
and
3,950 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,67 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
check_branch: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_build: ${{ steps.permitted.outputs.result }} | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Fetch remote branches | ||
run: | | ||
git fetch origin --depth=1 | ||
- name: Check if on permitted branch | ||
id: permitted | ||
run: | | ||
result= | ||
branchName=$(git branch -a --contains $GITHUB_SHA | grep 'remotes/origin/' || echo "") | ||
if [[ $branchName == *"master" || $branchName == *"-release" ]]; then | ||
result=true | ||
fi | ||
echo "result=${result}" >> "$GITHUB_OUTPUT" | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: check_branch | ||
permissions: | ||
contents: write | ||
|
||
if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_build }} | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1 | ||
with: | ||
cache: 'yarn' | ||
|
||
- name: Create GitHub release entry | ||
run: | | ||
body=$(node scripts/github-release.js) && | ||
curl \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/visgl/luma.gl/releases \ | ||
-d "${body}" \ | ||
-H "Authorization: token ${GITHUB_TOKEN}" | ||
- name: Login to NPM | ||
run: npm config set "//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}" | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Publish to NPM | ||
run: npx ocular-publish from-git |
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 |
---|---|---|
|
@@ -15,8 +15,8 @@ jobs: | |
node-version: [20] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- uses: volta-cli/action@v4 | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
|
@@ -36,6 +36,6 @@ jobs: | |
yarn test-ci | ||
- name: Coveralls | ||
uses: coverallsapp/github-action@master | ||
uses: coverallsapp/github-action@09b709cf6a16e30b0808ba050c7a6e8a5ef13f8d # v1.2.5 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
|
@@ -6,41 +6,46 @@ on: | |
- '*-release' | ||
|
||
jobs: | ||
publish-website: | ||
check_branch: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_deploy: ${{ endsWith(github.ref, steps.get_version.outputs.latest) }} | ||
|
||
if: github.repository_owner == 'visgl' | ||
steps: | ||
- name: Get version | ||
id: get_version | ||
run: | | ||
LATEST=$(npm show @luma.gl/core@latest version | grep -o -E "^[0-9]+\.[0-9]+") | ||
echo "latest=${LATEST}-release" >> "$GITHUB_OUTPUT" | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: check_branch | ||
|
||
permissions: | ||
contents: write | ||
|
||
if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_deploy }} | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
token: ${{ secrets.ADMIN_TOKEN }} | ||
token: ${{ secrets.WEBSITE_DEPLOY_TOKEN }} | ||
|
||
- name: Use Node.js | ||
uses: actions/[email protected] | ||
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1 | ||
with: | ||
node-version: '18.x' | ||
cache: 'yarn' | ||
|
||
- name: Get version | ||
id: get-version | ||
run: LATEST=$(npm show @luma.gl/core version | grep -o -E "^[0-9]+\.[0-9]+") && echo "::set-output name=latest::/${LATEST}-release" | ||
|
||
- name: Check version | ||
if: ${{ !endsWith(github.ref, steps.get-version.outputs.latest) }} | ||
- name: Install dependencies | ||
run: | | ||
echo "Website is only published from the latest release branch" | ||
yarn bootstrap | ||
(cd website && yarn) | ||
- name: Build website | ||
if: ${{ endsWith(github.ref, steps.get-version.outputs.latest) }} | ||
run: | | ||
yarn bootstrap | ||
cd website | ||
yarn | ||
yarn build | ||
run: (cd website && yarn build) | ||
|
||
- name: Deploy | ||
if: ${{ endsWith(github.ref, steps.get-version.outputs.latest) }} | ||
uses: JamesIves/[email protected] | ||
uses: JamesIves/github-pages-deploy-action@132898c54c57c7cc6b80eb3a89968de8fc283505 # 3.7.1 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: gh-pages | ||
|
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,53 @@ | ||
import {execSync} from 'child_process'; | ||
import {readFileSync} from 'fs'; | ||
|
||
// Get the latest tag | ||
const tag = getGitTag(); | ||
if (!tag) { | ||
console.error('TAG NOT FOUND'); | ||
process.exit(1); | ||
} | ||
|
||
// Parse changelog | ||
const changelog = getReleaseNotes(tag); | ||
if (!changelog) { | ||
console.error('CHANGELOG NOT FOUND'); | ||
process.exit(1); | ||
} | ||
|
||
// Publish release notes to GitHub | ||
// https://docs.github.com/en/rest/reference/repos#create-a-release | ||
const requestBody = { | ||
tag_name: tag, | ||
name: tag, | ||
body: changelog, | ||
prerelease: tag.search(/alpha|beta|rc/) > 0 | ||
}; | ||
|
||
console.log(JSON.stringify(requestBody)); | ||
|
||
function getGitTag() { | ||
try { | ||
return execSync('git describe --tags --exact-match HEAD', { | ||
stdio: [null, 'pipe', null], | ||
encoding: 'utf-8' | ||
}).trim(); | ||
} catch (err) { | ||
// not tagged | ||
return null; | ||
} | ||
} | ||
|
||
function getReleaseNotes(version) { | ||
let changelog = readFileSync('CHANGELOG.md', 'utf-8'); | ||
const header = changelog.match(new RegExp(`^###.*\\b${version.replace('v', '')}\\b.*$`, 'm')); | ||
if (!header) { | ||
return null; | ||
} | ||
changelog = changelog.slice(header.index + header[0].length); | ||
const endIndex = changelog.search(/^#/m); | ||
if (endIndex > 0) { | ||
changelog = changelog.slice(0, endIndex); | ||
} | ||
return changelog.trim(); | ||
} |
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,13 @@ | ||
/** | ||
* Verifies that CHANGELOG has been updated before publishing a new version | ||
*/ | ||
import {readFileSync} from 'fs'; | ||
|
||
const {version} = JSON.parse(readFileSync('lerna.json')); | ||
|
||
const changelog = readFileSync('CHANGELOG.md', 'utf-8'); | ||
const header = changelog.match(new RegExp(`^###.*\\b${version}\\b.*$`, 'm')); | ||
if (!header) { | ||
console.error(`Cannot find an entry for ${version} in CHANGELOG.md`); | ||
process.exit(1); | ||
} |
Oops, something went wrong.