-
Notifications
You must be signed in to change notification settings - Fork 6
Add daily .zip docs release workflow #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PratikP1
wants to merge
3
commits into
Community-Access:main
Choose a base branch
from
PratikP1:ci/docs-release
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: Docs Release | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 6 * * *' # Daily at 6:00 AM UTC | ||
| workflow_dispatch: # Allow manual trigger for first run after PR approval | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: docs-release | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build-and-release: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check if docs have changed since last release | ||
| id: changes | ||
| run: | | ||
| # On manual dispatch (first run), always build | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| echo "First run (manual dispatch) — building unconditionally." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # For scheduled runs, compare against the last release tag | ||
| LAST_TAG=$(git tag --list 'v[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' --sort=-version:refname | head -1) | ||
| if [ -z "$LAST_TAG" ]; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| echo "No previous release tag found — building unconditionally." | ||
| exit 0 | ||
| fi | ||
|
|
||
| DIFF=$(git diff --name-only "$LAST_TAG"..HEAD -- docs/ html/docs/) | ||
| if [ -n "$DIFF" ]; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| echo "Changes detected since $LAST_TAG in docs/ or html/docs/." | ||
| else | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| echo "No changes since $LAST_TAG — skipping release." | ||
| fi | ||
|
|
||
| - name: Set date tag | ||
| if: steps.changes.outputs.changed == 'true' | ||
| id: date | ||
| run: | | ||
| DATE=$(date -u +"%Y-%m-%d") | ||
| echo "date=$DATE" >> "$GITHUB_OUTPUT" | ||
| echo "tag=v$DATE" >> "$GITHUB_OUTPUT" | ||
| echo "zip_name=Git-Going-With-Git-$DATE.zip" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create zip of docs and html/docs | ||
| if: steps.changes.outputs.changed == 'true' | ||
| run: | | ||
| zip -r "${{ steps.date.outputs.zip_name }}" docs/ html/docs/ | ||
|
|
||
| - name: Delete existing release for today if it exists | ||
| if: steps.changes.outputs.changed == 'true' | ||
| run: | | ||
| gh release delete "${{ steps.date.outputs.tag }}" --yes --cleanup-tag 2>/dev/null || true | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PratikP1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Create GitHub release | ||
| if: steps.changes.outputs.changed == 'true' | ||
| run: | | ||
| gh release create "${{ steps.date.outputs.tag }}" \ | ||
| "${{ steps.date.outputs.zip_name }}" \ | ||
| --title "Docs Release ${{ steps.date.outputs.date }}" \ | ||
| --notes "Daily docs release for ${{ steps.date.outputs.date }}. Contains docs/ (Markdown) and html/docs/ (HTML)." \ | ||
| --latest | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Clean up old releases (keep last 10) | ||
| if: steps.changes.outputs.changed == 'true' | ||
| run: | | ||
| # List all releases sorted by date (newest first), skip the first 10 | ||
| RELEASES_TO_DELETE=$(gh release list --limit 100 --json tagName,createdAt \ | ||
| --jq 'sort_by(.createdAt) | reverse | .[10:] | .[].tagName' \ | ||
| | grep -E '^v[0-9]{4}-[0-9]{2}-[0-9]{2}$' || true) | ||
|
|
||
| if [ -z "$RELEASES_TO_DELETE" ]; then | ||
| echo "No old releases to clean up." | ||
| else | ||
| for TAG in $RELEASES_TO_DELETE; do | ||
| echo "Deleting release $TAG..." | ||
| gh release delete "$TAG" --yes --cleanup-tag 2>/dev/null || true | ||
| done | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.