nightly #25
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: nightly | |
| on: | |
| schedule: | |
| # Run at 2 AM UTC every day | |
| - cron: "0 2 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: "Force publish even if no changes" | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| check-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for changes since last release | |
| id: changes | |
| run: | | |
| # Get the latest release tag | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "No previous release found, will publish" | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Check if there are commits since the last tag | |
| COMMITS=$(git rev-list ${LATEST_TAG}..HEAD --count) | |
| if [ "$COMMITS" -gt 0 ] || [ "${{ inputs.force }}" = "true" ]; then | |
| echo "Found $COMMITS commits since $LATEST_TAG" | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "No changes since $LATEST_TAG" | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Bun | |
| if: steps.changes.outputs.has_changes == 'true' | |
| uses: ./.github/actions/setup-bun | |
| - name: Setup Node.js | |
| if: steps.changes.outputs.has_changes == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| if: steps.changes.outputs.has_changes == 'true' | |
| run: bun install | |
| - name: Set nightly version | |
| if: steps.changes.outputs.has_changes == 'true' | |
| id: version | |
| run: | | |
| DATE=$(date +%Y%m%d) | |
| # Read current version from package.json and increment patch | |
| CURRENT=$(jq -r '.version' packages/zee/package.json) | |
| # Strip any prerelease suffix (e.g., -alpha, -alpha.nightly.*) | |
| BASE=$(echo "$CURRENT" | sed 's/-.*//') | |
| # Parse major.minor.patch | |
| MAJOR=$(echo "$BASE" | cut -d. -f1) | |
| MINOR=$(echo "$BASE" | cut -d. -f2) | |
| PATCH=$(echo "$BASE" | cut -d. -f3) | |
| # Increment patch | |
| PATCH=$((PATCH + 1)) | |
| VERSION="${MAJOR}.${MINOR}.${PATCH}-alpha.nightly.${DATE}" | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| # Update package.json versions using sed (npm version fails on catalog: refs) | |
| sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" packages/zee/package.json | |
| sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" package.json | |
| echo "Updated versions to ${VERSION}" | |
| grep '"version"' packages/zee/package.json | |
| - name: Build | |
| if: steps.changes.outputs.has_changes == 'true' | |
| run: | | |
| cd packages/zee | |
| bun run build | |
| - name: Publish to npm | |
| if: steps.changes.outputs.has_changes == 'true' | |
| run: | | |
| cd packages/zee | |
| npm publish --access public --provenance --tag nightly | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| if: steps.changes.outputs.has_changes == 'true' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Generate changelog from commits | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -n "$LATEST_TAG" ]; then | |
| CHANGELOG=$(git log ${LATEST_TAG}..HEAD --pretty=format:"- %s" | head -20) | |
| else | |
| CHANGELOG="Initial nightly release" | |
| fi | |
| gh release create "v${VERSION}" \ | |
| --title "Nightly ${VERSION}" \ | |
| --notes "## Nightly Build | |
| **Version:** ${VERSION} | |
| **Date:** $(date +%Y-%m-%d) | |
| ### Changes | |
| ${CHANGELOG} | |
| ### Install | |
| \`\`\`bash | |
| npm install -g @zee/zee@nightly | |
| # or specific version | |
| npm install -g @zee/zee@${VERSION} | |
| \`\`\` | |
| " \ | |
| --prerelease | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Upload artifacts | |
| if: steps.changes.outputs.has_changes == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: zee-nightly-${{ steps.version.outputs.version }} | |
| path: packages/zee/dist |