|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "*" |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + id-token: write |
| 15 | + contents: write |
| 16 | + deployments: write |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - run: corepack enable |
| 23 | + |
| 24 | + - uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + cache: "yarn" |
| 27 | + cache-dependency-path: "yarn.lock" |
| 28 | + node-version-file: ".nvmrc" |
| 29 | + |
| 30 | + - if: github.ref_type == 'branch' |
| 31 | + run: | |
| 32 | + jq \ |
| 33 | + --arg build "$GITHUB_RUN_NUMBER" \ |
| 34 | + --arg commit "${GITHUB_SHA::8}" \ |
| 35 | + '.version = .version + "-dev." + $build + "+" + $commit' \ |
| 36 | + packages/cli/package.json > packages/cli/package.json.tmp |
| 37 | + mv packages/cli/package.json.tmp packages/cli/package.json |
| 38 | +
|
| 39 | + - run: yarn install |
| 40 | + |
| 41 | + - name: Build and pack CLI |
| 42 | + run: | |
| 43 | + yarn workspace docflow build |
| 44 | + mkdir -p out |
| 45 | + cd packages/cli |
| 46 | + yarn pack --out ../../out |
| 47 | +
|
| 48 | + - id: extract-changelog |
| 49 | + uses: dahlia/submark@5a5ff0a58382fb812616a5801402f5aef00f90ce |
| 50 | + with: |
| 51 | + input-file: CHANGELOG.md |
| 52 | + heading-level: 2 |
| 53 | + heading-title-text: version ${{ github.ref_name }} |
| 54 | + ignore-case: true |
| 55 | + omit-heading: true |
| 56 | + |
| 57 | + - run: cat ${{ steps.extract-changelog.outputs.output-file }} |
| 58 | + |
| 59 | + - name: Release |
| 60 | + uses: softprops/action-gh-release@v2 |
| 61 | + if: startsWith(github.ref, 'refs/tags/') |
| 62 | + with: |
| 63 | + body_path: ${{ steps.extract-changelog.outputs.output-file }} |
| 64 | + repository: ${{ github.repository }} |
| 65 | + generate_release_notes: false |
| 66 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + files: out/*.tgz |
| 68 | + |
| 69 | + - name: Publish to registry |
| 70 | + if: | |
| 71 | + github.event_name == 'push' && |
| 72 | + (github.ref_type == 'tag' || github.ref == 'refs/heads/main') |
| 73 | + run: | |
| 74 | + set -ex |
| 75 | + npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN" |
| 76 | + npm whoami |
| 77 | + if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then |
| 78 | + npm publish --provenance --access public *.tgz |
| 79 | + else |
| 80 | + npm publish --provenance --access public --tag dev *.tgz |
| 81 | + fi |
| 82 | + env: |
| 83 | + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 84 | + working-directory: ${{ github.workspace }}/out/ |
| 85 | + |
| 86 | + deploy-docs: |
| 87 | + if: github.event_name == 'push' && github.ref_type == 'tag' |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + - name: Checkout |
| 91 | + uses: actions/checkout@v4 |
| 92 | + |
| 93 | + - run: corepack enable |
| 94 | + |
| 95 | + - uses: actions/setup-node@v4 |
| 96 | + with: |
| 97 | + cache: "yarn" |
| 98 | + cache-dependency-path: "yarn.lock" |
| 99 | + node-version-file: ".nvmrc" |
| 100 | + |
| 101 | + - name: Install dependencies |
| 102 | + run: yarn install |
| 103 | + |
| 104 | + - name: Deploy a docs site |
| 105 | + run: |- |
| 106 | + cd docs |
| 107 | + yarn vercel deploy --yes --prod --token=${{ secrets.VERCEL_TOKEN }} |
0 commit comments