Update interactivity-router plugin to include a new helper function f… #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "🚀 Generate Examples Zips and Create Release" | |
| on: | |
| push: | |
| branches: | |
| - trunk # Or your default branch | |
| workflow_dispatch: | |
| jobs: | |
| zip-packages: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the repository | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # Set up Node.js and install dependencies | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '16' # Use your preferred Node.js version | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 8.7.1 | |
| - name: Install dependencies | |
| run: pnpm install | |
| # Create zips directory | |
| - name: Create zips directory | |
| run: mkdir -p zips | |
| # Run the plugin-zip script to generate zip files | |
| - name: Generate zip files | |
| run: | | |
| npm run deploy | |
| ls -la zips/ # Debug: List contents of zips directory | |
| # Install GitHub CLI | |
| - name: Install GitHub CLI | |
| run: sudo apt-get install -y gh | |
| # Authenticate with GitHub CLI | |
| - name: Authenticate GitHub CLI | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh auth setup-git -h github.com | |
| # Create GitHub Release | |
| - name: Create GitHub Release | |
| id: create_release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Create a dated tag for version tracking | |
| RELEASE_TAG="v$(date +'%Y%m%d%H%M%S')" | |
| echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV | |
| # Create the new release | |
| gh release create $RELEASE_TAG \ | |
| --title "Release $RELEASE_TAG" \ | |
| --notes "This release contains the latest package zips." | |
| # Upload the zips to the Release with consistent names | |
| - name: Upload Zips to Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| for file in zips/*.zip; do | |
| [ -e "$file" ] || continue | |
| # Extract the base name without path and extension | |
| filename=$(basename "$file") | |
| # Upload to the versioned release | |
| gh release upload "${{ env.RELEASE_TAG }}" "$file" | |
| done | |
| - name: Update or Create Latest Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Check if the latest release exists | |
| if gh release view latest; then | |
| # Check if the release is a draft and publish it if needed | |
| if gh release view latest --json isDraft --jq '.isDraft'; then | |
| echo "Publishing the draft release..." | |
| gh release edit latest --draft=false | |
| fi | |
| # Update the existing release | |
| gh release edit latest \ | |
| --title "Latest Release" \ | |
| --notes "This is always the latest release. For permanent links, use the dated releases." \ | |
| --latest | |
| else | |
| # Create the latest release if it doesn't exist | |
| gh release create latest \ | |
| --title "Latest Release" \ | |
| --notes "This is always the latest release. For permanent links, use the dated releases." \ | |
| --latest | |
| fi | |
| # Upload files to the latest release | |
| for file in zips/*.zip; do | |
| [ -e "$file" ] || continue | |
| gh release upload latest "$file" --clobber | |
| done |