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