|
| 1 | +# This workflow tags a release, builds front-end assets and sends various notifications & webhooks when a release has been created. |
| 2 | + |
| 3 | +# How it works: |
| 4 | +# 1. Add release notes to the CHANGELOG.md file. Commit & push them up. |
| 5 | +# 2. Create a git tag and push it up - `git tag <version number> && git push origin --tags` |
| 6 | +# 3. This action will create a release, using the latest notes from the CHANGELOG.md file. |
| 7 | +# 4. It'll build the front-end assets and attach them to the release. |
| 8 | +# 5. Finally, it'll comment on the PRs & Issues mentioned in the changelog to let everyone know a release has been tagged. |
| 9 | + |
| 10 | +name: Release |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + tags: |
| 15 | + - "v*" |
| 16 | + |
| 17 | +jobs: |
| 18 | + release: |
| 19 | + name: Prepare & Create Release |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v1 |
| 24 | + |
| 25 | + - name: Setup PHP |
| 26 | + uses: shivammathur/setup-php@v2 |
| 27 | + with: |
| 28 | + php-version: 8.2 |
| 29 | + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick |
| 30 | + tools: composer:v2 |
| 31 | + |
| 32 | + - name: Install NPM Dependencies |
| 33 | + run: npm install |
| 34 | + |
| 35 | + - name: Install Composer Dependencies |
| 36 | + run: composer install |
| 37 | + |
| 38 | + - name: Compile assets |
| 39 | + run: npm run build |
| 40 | + |
| 41 | + - name: Create zip |
| 42 | + run: tar -czvf dist.tar.gz dist |
| 43 | + |
| 44 | + - name: Get Changelog |
| 45 | + id: changelog |
| 46 | + uses: statamic/changelog-action@v1 |
| 47 | + with: |
| 48 | + version: ${{ github.ref }} |
| 49 | + |
| 50 | + - name: Create release |
| 51 | + id: create_release |
| 52 | + uses: actions/create-release@v1 |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + with: |
| 56 | + tag_name: ${{ github.ref }} |
| 57 | + release_name: ${{ github.ref }} |
| 58 | + body: ${{ steps.changelog.outputs.text }} |
| 59 | + prerelease: ${{ contains(github.ref, '-beta') }} |
| 60 | + |
| 61 | + - name: Upload zip to release |
| 62 | + |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + with: |
| 66 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 67 | + asset_path: ./dist.tar.gz |
| 68 | + asset_name: dist.tar.gz |
| 69 | + asset_content_type: application/tar+gz |
| 70 | + |
| 71 | + - name: Comment on related issues |
| 72 | + uses: duncanmcclean/[email protected] |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + with: |
| 76 | + version: ${{ github.ref }} |
| 77 | + changelog: ${{ steps.changelog.outputs.text }} |
0 commit comments