Skip to content

Publish a new release if available #7046

Publish a new release if available

Publish a new release if available #7046

Workflow file for this run

name: Publish a new release if available
on:
push:
branches:
- main
schedule:
# Run at minute 30 every 3 hours, starting from the hour 0 (12 midnight)
- cron: '30 0/3 * * *'
jobs:
create-github-release:
name: Create a new release in the GitHub repository if needed
runs-on: ubuntu-latest
steps:
- name: Checkout the main branch
uses: actions/checkout@v3
# Refer to https://stackoverflow.com/a/69116750 for running Kotlin scripts
- name: Use a specific Kotlin version
uses: fwilhe2/setup-kotlin@main
with:
version: 1.7.10
- name: Check if there is a new release
id: check-for-updates
run: kotlin scripts/check-for-updates.main.kts
- name: Create the new release notes
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
run: kotlin scripts/create-new-release-notes.main.kts
# See https://github.com/pandoc/pandoc-action-example
# and https://stackoverflow.com/a/70212129/8583692
# NOTE: This step produces the Markdown to be included as a release artifact.
# It could be used as the release body but had some minor formatting issues.
# For example, it contained unnecessary new lines in the body.
- name: Convert from HTML to markdown
uses: docker://pandoc/core:2.18.0
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
with:
# These are appended to "pandoc" command exactly like in terminal
args: "--from=html --to=markdown_strict --output=release-notes.md release-notes.html"
- name: Create the release
uses: ncipollo/release-action@v1
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
with:
tag: ${{ steps.check-for-updates.outputs.dateTag }}
commit: "main"
bodyFile: "release-notes.html"
artifacts: "release-notes.md, release-notes.html, release-notes.txt"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set RSS last update time
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
run: kotlin scripts/set-rss-last-update.main.kts
# Also see https://github.com/EndBug/add-and-commit
- name: Commit main changes
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
with:
commit_message: Update last RSS update time
file_pattern: last-rss-update.txt
# See https://github.community/t/how-to-commit-to-two-branches-from-an-action/17713
- name: Checkout the website branch
uses: actions/checkout@v3
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
with:
ref: website
clean: 'false'
- name: Update website content
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
run: kotlin scripts/update-website-content.main.kts
- name: Commit website changes
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ steps.check-for-updates.outputs.result == 'stale' }}
with:
branch: website
file_pattern: docs/*
commit_message: Update website content