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
chore: update CI setup #2079
chore: update CI setup #2079
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {execSync} from 'child_process'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could these scripts go into ocular so they don't have to be copied into each repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to keep it in each repo for now as we don't have standardized changelog format. |
||
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(); | ||
} |
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); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much delicate config to duplicate across repos, at some point create our own github action? Is that even possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that will take time to develop and test.