|
| 1 | +name: 'Publish new release' |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + types: |
| 8 | + - closed |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + name: Publish new release |
| 13 | + runs-on: ubuntu-latest |
| 14 | + # only merged pull requests that begin with 'release/' or 'hotfix/' must trigger this job |
| 15 | + if: github.event.pull_request.merged == true && |
| 16 | + (startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/')) |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Extract version from branch name (for release branches) |
| 20 | + if: startsWith(github.event.pull_request.head.ref, 'release/') |
| 21 | + run: | |
| 22 | + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" |
| 23 | + VERSION=${BRANCH_NAME#release/} |
| 24 | +
|
| 25 | + echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV |
| 26 | +
|
| 27 | + - name: Extract version from branch name (for hotfix branches) |
| 28 | + if: startsWith(github.event.pull_request.head.ref, 'hotfix/') |
| 29 | + run: | |
| 30 | + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" |
| 31 | + VERSION=${BRANCH_NAME#hotfix/} |
| 32 | +
|
| 33 | + echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV |
| 34 | +
|
| 35 | + - uses: actions/checkout@v3 |
| 36 | + |
| 37 | + - name: Use Node.js 18.x |
| 38 | + uses: actions/setup-node@v3 |
| 39 | + with: |
| 40 | + node-version: 18.x |
| 41 | + cache: 'npm' |
| 42 | + |
| 43 | + - name: Install Node modules |
| 44 | + run: npm ci |
| 45 | + |
| 46 | + - name: Build scripts |
| 47 | + run: npm run build-userscript |
| 48 | + |
| 49 | + - name: Extract release notes |
| 50 | + id: extract-release-notes |
| 51 | + uses: ffurrer2/extract-release-notes@v1 |
| 52 | + with: |
| 53 | + changelog_file: CHANGELOG.md |
| 54 | + |
| 55 | + - name: Release |
| 56 | + uses: softprops/action-gh-release@v1 |
| 57 | + with: |
| 58 | + target_commitish: ${{ github.event.pull_request.merge_commit_sha }} |
| 59 | + tag_name: ${{ env.RELEASE_VERSION }} |
| 60 | + name: ${{ env.RELEASE_VERSION }} |
| 61 | + draft: false |
| 62 | + prerelease: false |
| 63 | + body: ${{ steps.extract-release-notes.outputs.release_notes }} |
| 64 | + files: | |
| 65 | + ./dist/qc-ext.user.js |
| 66 | + ./dist/qc-ext.meta.js |
| 67 | +
|
| 68 | + - name: Merge main into dev branch |
| 69 | + uses: thomaseizinger/create-pull-request@1.0.0 |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + with: |
| 73 | + head: main |
| 74 | + base: develop |
| 75 | + title: Merge main into develop branch |
| 76 | + body: | |
| 77 | + This PR merges the main branch back into develop. |
| 78 | + This happens to ensure that the updates that happend on the release branch, i.e. CHANGELOG and manifest updates are also present on the dev branch. |
0 commit comments