Skip to content

Commit

Permalink
Publish NPM packages from CI (#8828)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Apr 24, 2024
1 parent 677e9ee commit 8acba03
Show file tree
Hide file tree
Showing 5 changed files with 2,561 additions and 2,739 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ jobs:
release-notes:
runs-on: ubuntu-latest

if: github.repository_owner == 'visgl'
if: github.repository_owner == 'visgl' && (github.ref == 'refs/heads/master' || endsWith(github.ref, '-release'))

env:
ADMIN_TOKEN: ${{ secrets.ADMIN_TOKEN }}
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -28,7 +29,7 @@ jobs:
with:
node-version: '18.x'

- name: Publish release
- name: Create GitHub release entry
run: |
body=$(node scripts/github-release.js) &&
curl \
Expand All @@ -37,3 +38,12 @@ jobs:
https://api.github.com/repos/visgl/deck.gl/releases \
-d "${body}" \
-H "Authorization: token ${ADMIN_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
7 changes: 1 addition & 6 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"lerna": "2.0.0",
"version": "9.0.0-beta.10",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"modules/*"
],
"command": {
"bootstrap": {}
}
]
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
"postinstall": "./scripts/postinstall.sh",
"clean": "ocular-clean",
"build": "npm run clean && ocular-build && lerna run build",
"version": "npm run build",
"version": "node scripts/verify-changelog.js && git add CHANGELOG.md",
"lint": "ocular-lint",
"cover": "ocular-test cover",
"publish": "ocular-publish",
"publish-beta": "ocular-publish version-only-beta",
"publish-prod": "ocular-publish version-only-prod",
"start": "open https://deck.gl/docs/get-started/getting-started",
"test": "ocular-test",
"test-ci": "ocular-lint && ocular-test node && ocular-test cover",
Expand Down Expand Up @@ -53,7 +54,7 @@
"@math.gl/proj4": "^4.0.0",
"@probe.gl/bench": "^4.0.9",
"jsdom": "^20.0.0",
"ocular-dev-tools": "2.0.0-alpha.29",
"ocular-dev-tools": "2.0.0-alpha.30",
"pre-commit": "^1.2.2",
"pre-push": "^0.1.1",
"puppeteer": "^22.4.0",
Expand Down
13 changes: 13 additions & 0 deletions scripts/verify-changelog.js
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);
}
Loading

0 comments on commit 8acba03

Please sign in to comment.