|
| 1 | +name: Release PR |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Release version" |
| 8 | + required: true |
| 9 | + default: 0.0.0 |
| 10 | + type: string |
| 11 | + |
| 12 | + workflow_call: |
| 13 | + inputs: |
| 14 | + version: |
| 15 | + default: 0.0.0 |
| 16 | + type: string |
| 17 | + push: |
| 18 | + branch: [main] |
| 19 | + |
| 20 | +jobs: |
| 21 | + release-pr: |
| 22 | + runs-on: "macos-latest" |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + node-version: [16.x] |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v3 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Check Version |
| 32 | + run: bash -c '$([[ "${{ inputs.version }}" =~ ^([0-9]+\.){2}[0-9]+ ]])' |
| 33 | + |
| 34 | + - run: | |
| 35 | + git config --global user.name "github" |
| 36 | + git config --global user.email "noreply@github.com" |
| 37 | +
|
| 38 | + - name: Use Node.js ${{ matrix.node-version }} |
| 39 | + uses: actions/setup-node@v3 |
| 40 | + with: |
| 41 | + node-version: ${{ matrix.node-version }} |
| 42 | + cache: "yarn" |
| 43 | + |
| 44 | + - run: yarn install --immutable |
| 45 | + |
| 46 | + - name: Changelog |
| 47 | + id: create-changelog |
| 48 | + run: | |
| 49 | + TMPFILE=/tmp/tmpfile |
| 50 | + bash scripts/generate_changelog.sh $TMPFILE |
| 51 | + cat $TMPFILE >> $GITHUB_STEP_SUMMARY |
| 52 | + cat $TMPFILE >> CHANGELOG.md |
| 53 | + echo "changelog_file=$TMPFILE" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + - name: Bump version |
| 56 | + run: yarn workspaces foreach version ${{ inputs.version }} |
| 57 | + if: ${{ inputs.version }} != "0.0.0" |
| 58 | + |
| 59 | + - name: Create Branch |
| 60 | + id: create-branch |
| 61 | + run: | |
| 62 | + COMMIT_SHA=$(git rev-parse --short HEAD) |
| 63 | + BRANCH=releases/draft-$COMMIT_SHA-$(date +%s) |
| 64 | + git checkout -b $BRANCH |
| 65 | + git add CHANGELOG.md **/package.json |
| 66 | + git status |
| 67 | + git commit -m "Changelog & version bump to ${{ inputs.version }}" |
| 68 | + git push origin HEAD |
| 69 | + echo "branch_name=$BRANCH" >> $GITHUB_OUTPUT |
| 70 | + if: ${{ inputs.version }} != "0.0.0" |
| 71 | + |
| 72 | + - name: Create PR |
| 73 | + run: | |
| 74 | + gh pr create -B main -H ${{ steps.create-branch.outputs.branch_name }} --title "Release: v${{ inputs.version }}" --body-file ${{ steps.create-changelog.outputs.changelog_file }} |
| 75 | + rm ${{ steps.create-changelog.outputs.changelog_file }} |
| 76 | + env: |
| 77 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + if: ${{ inputs.version }} != "0.0.0" |
0 commit comments