|
6 | 6 | - v* |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - release-notes: |
10 | | - runs-on: ubuntu-22.04 |
| 9 | + check_branch: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + should_build: ${{ steps.permitted.outputs.result }} |
11 | 13 |
|
12 | | - if: github.repository_owner == 'visgl' |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 16 | + |
| 17 | + - name: Fetch remote branches |
| 18 | + run: | |
| 19 | + git fetch origin --depth=1 |
13 | 20 |
|
| 21 | + - name: Check if on permitted branch |
| 22 | + id: permitted |
| 23 | + run: | |
| 24 | + result= |
| 25 | + if git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/master$'; then |
| 26 | + result=true |
| 27 | + elif git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/.*-release$'; then |
| 28 | + result=true |
| 29 | + fi |
| 30 | + echo "result=${result}" >> "$GITHUB_OUTPUT" |
| 31 | +
|
| 32 | + release: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + needs: check_branch |
14 | 35 | permissions: |
15 | 36 | contents: write |
16 | 37 |
|
| 38 | + if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_build }} |
| 39 | + |
17 | 40 | env: |
18 | 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} |
19 | 43 |
|
20 | 44 | steps: |
21 | 45 | - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
22 | | - |
23 | | - - name: Use Node.js |
24 | | - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 |
| 46 | + - uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1 |
25 | 47 | with: |
26 | | - node-version: '18.x' |
| 48 | + cache: 'yarn' |
27 | 49 |
|
28 | | - - name: Publish release |
29 | | - run: | |
30 | | - body=$(node scripts/github-release.js) && |
31 | | - curl \ |
32 | | - -X POST \ |
33 | | - -H "Accept: application/vnd.github.v3+json" \ |
34 | | - https://api.github.com/repos/visgl/react-map-gl/releases \ |
35 | | - -d "${body}" \ |
36 | | - -H "Authorization: token ${GITHUB_TOKEN}" |
| 50 | + - name: Install dependencies |
| 51 | + run: yarn |
| 52 | + |
| 53 | + - name: Build packages |
| 54 | + run: npm run build |
| 55 | + |
| 56 | + - name: Run tests from transpiled code |
| 57 | + run: npx ocular-test dist |
| 58 | + |
| 59 | + - name: Login to NPM |
| 60 | + run: npm config set "//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}" |
| 61 | + |
| 62 | + - name: Publish to NPM |
| 63 | + run: npx ocular-publish from-git |
0 commit comments