Skip to content

Commit

Permalink
build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Oct 3, 2024
1 parent 59e8847 commit 1462de5
Show file tree
Hide file tree
Showing 7 changed files with 11,238 additions and 8,360 deletions.
57 changes: 42 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,58 @@ on:
- v*

jobs:
release-notes:
check_branch:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.permitted.outputs.result }}

if: github.repository_owner == 'visgl'
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=
if git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/master$'; then
result=true
elif git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/.*-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

- name: Use Node.js
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1
with:
node-version: '18.x'
cache: 'yarn'

- name: Publish release
run: |
body=$(node scripts/github-release.js) &&
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/visgl/react-maplibre-gl/releases \
-d "${body}" \
-H "Authorization: token ${GITHUB_TOKEN}"
- name: Install dependencies
run: yarn

- name: Build packages
run: npm run build

- name: Run tests from transpiled code
run: npx ocular-test dist

- name: Login to NPM
run: npm config set "//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}"

- name: Publish to NPM
run: npx ocular-publish from-git
24 changes: 15 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@ name: test
on:
push:
branches:
- master
- master
pull_request:

jobs:
test-node:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1
with:
node-version: '18.x'
cache: "yarn"

- name: Install dependencies
run: |
yarn bootstrap
yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Build code
run: |
yarn build
- name: Run tests
env:
VITE_MAPBOX_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }}
run: |
yarn test ci
- name: Run lint
run: |
yarn lint
- name: Coveralls
uses: coverallsapp/github-action@09b709cf6a16e30b0808ba050c7a6e8a5ef13f8d # v1.2.5
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- name: Get version
id: get_version
run: |
LATEST=$(npm show react-maplibre-gl version | grep -o -E "^[0-9]+\.[0-9]+")
packageFile=$(if [ -d modules ]; then ls modules/*/package.json | head -n 1; else echo package.json; fi)
packageName=$(jq -r '.name' $packageFile)
LATEST=$(npm show "${packageName}@latest" version | grep -o -E "^[0-9]+\.[0-9]+")
echo "latest=${LATEST}-release" >> "$GITHUB_OUTPUT"
deploy:
Expand All @@ -33,15 +35,13 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
token: ${{ secrets.WEBSITE_DEPLOY_TOKEN }}

- name: Use Node.js
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1
with:
node-version: '18.x'
cache: 'yarn'

- name: Install dependencies
run: |
yarn bootstrap
yarn
(cd website && yarn)
- name: Build website
Expand Down
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
"README.md"
],
"scripts": {
"bootstrap": "yarn && ocular-bootstrap && npm run build",
"typecheck": "tsc -p tsconfig.build.json --noEmit",
"bootstrap": "PUPPETEER_SKIP_DOWNLOAD=true yarn && ocular-bootstrap",
"build": "ocular-clean && ocular-build",
"lint": "ocular-lint",
"cover": "ocular-test cover",
"publish-prod": "ocular-publish prod",
"publish-beta": "ocular-publish beta",
"test": "yarn typecheck && ocular-test",
"publish-beta": "ocular-publish version-only-beta",
"publish-prod": "ocular-publish version-only-prod",
"test": "ocular-test",
"test-fast": "yarn typecheck && ocular-test node",
"metrics": "ocular-metrics",
"update-release-branch": "scripts/update-release-branch.sh"
Expand All @@ -63,6 +62,10 @@
"react-dom": "^18.0.0",
"typescript": "^5.0.0"
},
"volta": {
"node": "20.15.1",
"yarn": "4.4.1"
},
"pre-commit": [
"test-fast"
]
Expand Down
Loading

0 comments on commit 1462de5

Please sign in to comment.