|
| 1 | +name: release |
| 2 | +on: |
| 3 | + # Automatically run when a semver tag is pushed |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + # setup strategy matrix, so we can share same pnpm cache |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ubuntu-latest] |
| 14 | + node-version: [18] |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + |
| 17 | + steps: |
| 18 | + # Checkout action retreive the source (git clone) |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + fetch-depth: 0 # needed to retreive all git history |
| 22 | + |
| 23 | + # Enable corepack, note that nodejs is already installed |
| 24 | + - run: corepack enable |
| 25 | + |
| 26 | + # Setup pnpm with cache |
| 27 | + - uses: actions/setup-node@v3 |
| 28 | + with: |
| 29 | + node-version: ${{ matrix.node-version }} |
| 30 | + cache: "pnpm" |
| 31 | + |
| 32 | + # Compute tag and capitalized product name |
| 33 | + - id: meta |
| 34 | + name: release meta |
| 35 | + run: | |
| 36 | + project=${GITHUB_REPOSITORY#*/} |
| 37 | + echo ::set-output name=project::${project} |
| 38 | + echo ::set-output name=project-capitalized::${project^} |
| 39 | + echo ::set-output name=tag::${GITHUB_REF#refs/tags/} |
| 40 | +
|
| 41 | + # This is where we generate releases assets. |
| 42 | + # It use a github action in the current directory |
| 43 | + # which contains a shell script to create the archive. |
| 44 | + # The archive path is stored in the output action |
| 45 | + - id: build_template |
| 46 | + name: build release template |
| 47 | + uses: ./.github/actions/build-template-action |
| 48 | + with: |
| 49 | + tag: ${{ steps.meta.outputs.tag }} |
| 50 | + project: ${{ steps.meta.outputs.project }} |
| 51 | + |
| 52 | + # We re-generate the changelog using a subset of standard-version |
| 53 | + # The content is generated in a temp /CHANGELOG_RELEASE.md file |
| 54 | + # It is used to generate the body of the github release |
| 55 | + - id: changelog |
| 56 | + name: release changelog |
| 57 | + run: | |
| 58 | + pnpm dlx conventional-changelog-cli -p conventionalcommits -r 2 -o ${{ github.workspace }}/CHANGELOG_RELEASE.md |
| 59 | + cat ${{ github.workspace }}/CHANGELOG_RELEASE.md |
| 60 | +
|
| 61 | + # Prepare the draft github release |
| 62 | + - id: create_release |
| 63 | + name: create github draft release |
| 64 | + uses: softprops/action-gh-release@v1 |
| 65 | + with: |
| 66 | + # Use outputs from meta and changelog |
| 67 | + tag_name: ${{ steps.meta.outputs.tag }} |
| 68 | + name: ${{ steps.meta.outputs.project-capitalized }} ${{ steps.meta.outputs.tag }} |
| 69 | + body_path: ${{ github.workspace }}/CHANGELOG_RELEASE.md |
| 70 | + prerelease: false |
| 71 | + # The draft is required to allow file upload |
| 72 | + draft: true |
| 73 | + fail_on_unmatched_files: true |
| 74 | + # Here we bind files built by custom actions to the release |
| 75 | + files: | |
| 76 | + ${{ github.workspace }}/${{ steps.build_template.outputs.filepath }} |
| 77 | +
|
| 78 | + # Publish the github release |
| 79 | + # Dojo listen to those events |
| 80 | + - name: publish github draft release |
| 81 | + uses: eregon/publish-release@v1 |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.APP_GITHUB_TOKEN }} |
| 84 | + with: |
| 85 | + release_id: ${{ steps.create_release.outputs.id }} |
0 commit comments