|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-and-release: |
| 10 | + name: Build & Publish Release |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Use Node.js 20 |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: 20 |
| 23 | + cache: yarn |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: yarn install --frozen-lockfile |
| 27 | + |
| 28 | + - name: Build project |
| 29 | + run: yarn build |
| 30 | + |
| 31 | + - name: Run tests |
| 32 | + run: yarn test --if-present |
| 33 | + |
| 34 | + # ------------------------------ |
| 35 | + # Auto Changelog Generation |
| 36 | + # ------------------------------ |
| 37 | + - name: Install git-cliff |
| 38 | + run: | |
| 39 | + curl -sSL https://github.com/orhun/git-cliff/releases/latest/download/git-cliff-Linux-x86_64.tar.gz \ |
| 40 | + | tar -xz |
| 41 | + sudo mv git-cliff /usr/local/bin/ |
| 42 | +
|
| 43 | + - name: Generate Changelog |
| 44 | + run: | |
| 45 | + git-cliff --tag ${GITHUB_REF#refs/tags/} > RELEASE_CHANGELOG.md |
| 46 | +
|
| 47 | + # ------------------------------ |
| 48 | + # Package Release Files |
| 49 | + # ------------------------------ |
| 50 | + - name: Archive build output |
| 51 | + run: | |
| 52 | + mkdir -p release |
| 53 | + cp -r dist release/ |
| 54 | + cp package.json release/ |
| 55 | + cp yarn.lock release/ |
| 56 | + cp RELEASE_CHANGELOG.md release/ |
| 57 | +
|
| 58 | + # ------------------------------ |
| 59 | + # Publish GitHub Release |
| 60 | + # ------------------------------ |
| 61 | + - name: Create GitHub Release |
| 62 | + uses: softprops/action-gh-release@v1 |
| 63 | + with: |
| 64 | + body_path: RELEASE_CHANGELOG.md |
| 65 | + files: | |
| 66 | + release/** |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments