|
| 1 | +name: release |
1 | 2 | on:
|
2 | 3 | workflow_dispatch:
|
3 | 4 | push:
|
4 | 5 | branches:
|
5 | 6 | - main
|
6 |
| -name: release |
| 7 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 8 | +env: |
| 9 | + CI: true |
7 | 10 | jobs:
|
8 |
| - changeFinder: |
9 |
| - runs-on: ubuntu-latest |
10 |
| - outputs: |
11 |
| - nodePaths: ${{ steps.interrogate.outputs.nodePaths }} |
12 |
| - steps: |
13 |
| - - uses: actions/checkout@v2 |
14 |
| - - id: interrogate |
15 |
| - uses: actions/github-script@v4 |
16 |
| - with: |
17 |
| - github-token: ${{secrets.GITHUB_TOKEN}} |
18 |
| - script: | |
19 |
| - const {execSync} = require('child_process'); |
20 |
| - const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); |
21 |
| - const latestRelease = await github.repos.getLatestRelease({ |
22 |
| - owner, |
23 |
| - repo |
24 |
| - }); |
25 |
| - console.log(`latest release: ${JSON.stringify(latestRelease.data)}`); |
26 |
| - execSync('git pull --tags'); |
27 |
| - execSync(`git reset --hard ${latestRelease.data.tag_name}`); |
28 |
| - const status = execSync(`git diff --name-only origin/main`, { encoding: 'utf-8'}); |
29 |
| - console.log(status); |
30 |
| - const changes = status.split('\n'); |
31 |
| - let nodePaths = new Set(); |
32 |
| - for (const change of changes) { |
33 |
| - if (change.startsWith('packages/')) { |
34 |
| - const [,library] = change.split('/'); |
35 |
| - nodePaths.add(library); |
36 |
| - }; |
37 |
| - } |
38 |
| - nodePaths = Array.from(nodePaths); |
39 |
| - if(nodePaths.length === 0){ |
40 |
| - console.log(`::warning::No changes found, release will be skipped.`) |
41 |
| - } |
42 |
| - console.log(`::set-output name=nodePaths::${JSON.stringify(nodePaths)}`); |
43 |
| - release-pr: |
44 |
| - runs-on: ubuntu-latest |
45 |
| - needs: changeFinder |
46 |
| - if: ${{ fromJson(needs.changeFinder.outputs.nodePaths)[0] != '' }} |
47 |
| - strategy: |
48 |
| - fail-fast: false |
49 |
| - matrix: |
50 |
| - package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}} |
51 |
| - steps: |
52 |
| - - uses: google-github-actions/release-please-action@v2 |
53 |
| - id: release-please |
54 |
| - with: |
55 |
| - path: packages/${{ matrix.package }} |
56 |
| - token: ${{ secrets.GITHUB_TOKEN }} |
57 |
| - release-type: node |
58 |
| - package-name: "@web-std/${{ matrix.package }}" |
59 |
| - monorepo-tags: true |
60 |
| - changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Changes","hidden":false},{"type":"chore","section":"Changes","hidden":false}]' |
61 |
| - command: release-pr |
62 | 11 | release:
|
| 12 | + name: release |
| 13 | + if: ${{ github.repository == 'remix-run/web-std-io' }} |
63 | 14 | runs-on: ubuntu-latest
|
64 |
| - needs: changeFinder |
65 |
| - if: ${{ fromJson(needs.changeFinder.outputs.nodePaths)[0] != '' }} |
66 |
| - strategy: |
67 |
| - fail-fast: false |
68 |
| - matrix: |
69 |
| - package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}} |
70 | 15 | steps:
|
71 |
| - - uses: GoogleCloudPlatform/release-please-action@v2 |
72 |
| - id: release |
73 |
| - with: |
74 |
| - path: packages/${{ matrix.package }} |
75 |
| - token: ${{ secrets.GITHUB_TOKEN }} |
76 |
| - release-type: node |
77 |
| - package-name: "@web-std/${{ matrix.package }}" |
78 |
| - monorepo-tags: true |
79 |
| - changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Changes","hidden":false},{"type":"chore","section":"Changes","hidden":false}]' |
80 |
| - command: github-release |
81 |
| - # The logic below handles the npm publication: |
82 | 16 | - name: Checkout
|
83 |
| - uses: actions/checkout@v2 |
84 |
| - # these if statements ensure that a publication only occurs when |
85 |
| - # a new release is created: |
86 |
| - if: ${{ steps.release.outputs.release_created }} |
87 |
| - - name: Setup |
88 |
| - uses: actions/setup-node@v2 |
| 17 | + uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + - name: Setup Node |
| 21 | + uses: actions/setup-node@v3 |
89 | 22 | with:
|
90 | 23 | node-version: 16
|
91 |
| - registry-url: https://registry.npmjs.org/ |
92 |
| - if: ${{ steps.release.outputs.release_created }} |
| 24 | + cache: 'yarn' |
93 | 25 | - name: Install
|
94 |
| - uses: bahmutov/npm-install@v1 |
95 |
| - if: ${{ steps.release.outputs.release_created }} |
96 |
| - - name: Publish |
97 |
| - if: ${{ steps.release.outputs.release_created }} |
98 |
| - env: |
99 |
| - NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} |
| 26 | + run: yarn install --frozen-lockfile |
| 27 | + - name: Auth |
100 | 28 | run: |
|
101 |
| - cd packages/${{ matrix.package }} |
102 |
| - npm publish --access=public |
| 29 | + echo "registry=https://registry.npmjs.org" >> ~/.npmrc |
| 30 | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc |
| 31 | +
|
| 32 | + # This action has two responsibilities. The first time the workflow runs |
| 33 | + # (initial push to `main`) it will create a new branch and then PR back |
| 34 | + # to `main` with the related changes for the new version. After the PR |
| 35 | + # is merged, the workflow will run again and this action will publish to |
| 36 | + # npm. |
| 37 | + - name: PR / Publish |
| 38 | + id: changesets |
| 39 | + uses: changesets/action@v1 |
| 40 | + with: |
| 41 | + version: yarn version-bump |
| 42 | + commit: "chore: Update version for release" |
| 43 | + title: "chore: Update version for release" |
| 44 | + publish: yarn release |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments