|
| 1 | +name: Publish |
| 2 | +on: |
| 3 | + # NOTE: avoid using the manual execution unless is the only way to fix some issue, |
| 4 | + # rather retry failed jobs in case of flakes. The manual execution can potentially |
| 5 | + # cause the tags to point to a different commit that the one used to publish |
| 6 | + # the packages |
| 7 | + workflow_dispatch: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + publish: |
| 14 | + if: | |
| 15 | + github.event_name == 'workflow_dispatch' || |
| 16 | + startsWith(github.event.head_commit.message, 'chore(release): bump package versions') |
| 17 | +
|
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + # don't checkout a detatched HEAD |
| 24 | + ref: ${{ github.head_ref }} |
| 25 | + |
| 26 | + # this is important so git log has the whole history |
| 27 | + fetch-depth: '0' |
| 28 | + |
| 29 | + - name: Setup git |
| 30 | + run: | |
| 31 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 32 | + git config --local user.name "github-actions[bot]" |
| 33 | +
|
| 34 | + - name: "Use Node.js 14" |
| 35 | + uses: actions/setup-node@v3 |
| 36 | + with: |
| 37 | + node-version: 20.16.0 |
| 38 | + |
| 39 | + |
| 40 | + run: npm install -g [email protected] |
| 41 | + |
| 42 | + - name: Install Dependencies |
| 43 | + run: | |
| 44 | + npm run bootstrap-ci |
| 45 | + shell: bash |
| 46 | + |
| 47 | + - name: "Publish what is not already in NPM" |
| 48 | + env: |
| 49 | + NPM_TOKEN: ${{ secrets.DEVTOOLSBOT_NPM_TOKEN }} |
| 50 | + run: | |
| 51 | + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc |
| 52 | + npm config list |
| 53 | + echo "Publishing packages as $(npm whoami)" |
| 54 | + git update-index --assume-unchanged .npmrc |
| 55 | + npm run publish-packages |
| 56 | +
|
| 57 | + - name: "Publish tags" |
| 58 | + run: | |
| 59 | + npx lerna list -a --json | \ |
| 60 | + jq -r '.[] | .name + "@" + .version' | \ |
| 61 | + xargs -i sh -c "git tag -a {} -m {} || true" |
| 62 | + git push --follow-tags |
0 commit comments