|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + release: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v5 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Setup Node.js |
| 20 | + uses: actions/setup-node@v5 |
| 21 | + with: |
| 22 | + node-version: '22' |
| 23 | + |
| 24 | + - name: Install pnpm |
| 25 | + uses: pnpm/action-setup@v4 |
| 26 | + with: |
| 27 | + version: 10.4.1 |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: pnpm install --frozen-lockfile |
| 31 | + |
| 32 | + - name: Run build |
| 33 | + run: pnpm build |
| 34 | + |
| 35 | + - name: Create tarball |
| 36 | + run: | |
| 37 | + tar -czf excalidraw.tar.gz dist/ |
| 38 | +
|
| 39 | + - name: Configure Git |
| 40 | + run: | |
| 41 | + git config user.name "github-actions[bot]" |
| 42 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 43 | +
|
| 44 | + - name: Generate changelog and bump version |
| 45 | + id: version |
| 46 | + run: | |
| 47 | + changelogen --bump --output CHANGELOG.md |
| 48 | +
|
| 49 | + NEW_VERSION="v$(node -p "require('./package.json').version")" |
| 50 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 51 | +
|
| 52 | + - name: Commit changes |
| 53 | + run: | |
| 54 | + git add package.json CHANGELOG.md |
| 55 | + git commit -m "chore(release): ${{ steps.version.outputs.new_version }}" |
| 56 | +
|
| 57 | + - name: Create tag |
| 58 | + run: git tag ${{ steps.version.outputs.new_version }} |
| 59 | + |
| 60 | + - name: Push changes |
| 61 | + run: | |
| 62 | + git push origin main |
| 63 | + git push origin ${{ steps.version.outputs.new_version }} |
| 64 | +
|
| 65 | + - name: Extract changelog for release |
| 66 | + id: changelog |
| 67 | + run: | |
| 68 | + CHANGELOG=$(awk '/^## /{if(++count==2) exit} count==1' CHANGELOG.md | sed '1d') |
| 69 | + echo "changelog<<EOF" >> $GITHUB_OUTPUT |
| 70 | + echo "$CHANGELOG" >> $GITHUB_OUTPUT |
| 71 | + echo "EOF" >> $GITHUB_OUTPUT |
| 72 | +
|
| 73 | + - name: Create GitHub Release |
| 74 | + uses: softprops/action-gh-release@v2 |
| 75 | + with: |
| 76 | + tag_name: ${{ steps.version.outputs.new_version }} |
| 77 | + name: Release ${{ steps.version.outputs.new_version }} |
| 78 | + body: ${{ steps.changelog.outputs.changelog }} |
| 79 | + draft: false |
| 80 | + prerelease: false |
| 81 | + files: excalidraw.tar.gz |
0 commit comments