diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d10569c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + publish-npm: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version-file: '.nvmrc' + cache: 'npm' + registry-url: 'https://registry.npmjs.org/' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Publish to NPM + run: | + echo "Publishing to NPM..." + npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + announce-patreon: + runs-on: ubuntu-latest + needs: publish-npm + permissions: + contents: read + + steps: + - name: Extract version from tag + id: version + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Post to Patreon + run: | + curl -X POST "https://www.patreon.com/api/oauth2/v2/posts" \ + -H "Authorization: Bearer ${{ secrets.PATREON_ACCESS_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d @- << 'EOF' + { + "data": { + "type": "post", + "attributes": { + "title": "📦 Write CLI v${{ steps.version.outputs.version }} Released!", + "content": "A new version of the Write CLI tool has been released! 🎉\n\n**Version:** ${{ steps.version.outputs.version }}\n**Release Notes:** ${{ github.event.release.html_url }}\n**NPM Package:** https://www.npmjs.com/package/@demccormack/write\n\nInstall with: `npm install -g @demccormack/write`\n\nThank you for your support! ❤️", + "is_paid": false, + "post_type": "text_only" + } + } + } + EOF diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 0000000..b7264d1 --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,58 @@ +name: Tag Release + +on: + workflow_dispatch: + push: + tags: + - 'v*' + +jobs: + create-release: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: read + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Create NPM package tarball + run: npm pack + + - name: Create release assets archive + run: | + mkdir -p release-assets + cp -r dist release-assets/ + cp *.tgz release-assets/ + tar -czf release-assets.tar.gz -C release-assets . + + - name: Extract version from tag + id: version + run: echo "version=${GITHUB_REF#refs/tags/v}" | tee -a $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.ref_name }} + name: Release ${{ github.ref_name }} + draft: true + generate_release_notes: true + fail_on_unmatched_files: true + files: | + *.tgz + release-assets.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/templates/build.yml b/src/templates/build.yml index 568dd85..4472d62 100644 --- a/src/templates/build.yml +++ b/src/templates/build.yml @@ -4,7 +4,6 @@ on: push: branches: [main] pull_request: - branches: [main] jobs: build: @@ -12,22 +11,22 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup LaTeX - uses: xu-cheng/latex-action@v3 + uses: xu-cheng/latex-action@v4 with: root_file: main.tex - name: Upload PDF - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: ${{ github.event.repository.name }}-pdf path: main.pdf - name: Create Release (on tag) if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: main.pdf env: