Skip to content

Cut a new release automatically each month #8

Cut a new release automatically each month

Cut a new release automatically each month #8

Workflow file for this run

name: Automated Release
on:
push:
branches:
- master
pull_request:
# schedule:
# # Runs at 2:00 AM UTC on the first Saturday of every month
# - cron: '0 2 * * 6'
# workflow_dispatch: # Allow manual triggering of the workflow
jobs:
check-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for Blocking Issues/PRs
id: check_blocks
uses: actions/github-script@v6
with:
script: |
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: 'blocks-release',
state: 'open'
});
if (issues.length > 0) {
core.setOutput('block_release', 'true');
core.setOutput('blocking_items', issues.map(issue => `- ${issue.title} (#${issue.number})`).join("\n"));
} else {
core.setOutput('block_release', 'false');
}
- name: Stop if Blocks Exist
if: steps.check-blocks.outputs.block_release == 'true'
run: |
echo "Blocking issues/PRs detected:"
echo "${{ steps.check-blocks.outputs.blocking_items }}"
exit 1
- name: Get Latest Tag
id: get_latest_tag
run: |
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "v0.0.0")
echo "Latest tag: $latest_tag"
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
- name: Bump Version
id: bump_version
run: |
IFS='.' read -r major minor patch <<< "${{ env.latest_tag }}"
new_minor=$((minor + 1))
new_tag="v$major.$new_minor.0"
echo "New tag: $new_tag"
echo "new_tag=$new_tag" >> $GITHUB_ENV
- name: Generate Release Notes
id: generate_notes
uses: mikepenz/release-changelog-builder-action@v4
with:
fromTag: ${{ env.latest_tag }}
toTag: "HEAD"
failOnError: true
configurationJson: |
{
"pr_template": "#{{TITLE}} by #{{AUTHOR}} in #{{URL}}",
"categories": [
{
"title": "Features ✨",
"labels": ["feature"]
},
{
"title": "Enhancements 🔥",
"labels": ["enhancement"]
},
{
"title": "Fixes 🔧",
"labels": ["bug"]
},
{
"title": "Maintenance ⚙️",
"labels": ["maintenance"]
},
{
"title": "Docs 📖",
"labels": ["docs"]
},
{
"title": "I18n 🌎",
"labels": ["i18n"]
},
{
"title": "Performance Improvements 📊",
"labels": ["performance"]
},
{
"title": "💬 Other",
"labels": ["other"]
},
{
"title": "📦 Dependencies",
"labels": ["dependencies"]
}
],
"ignore_labels": ["ignore-for-release"]
}
- name: Print Release Notes
run: |
echo "Release Notes:"
echo "${{ steps.generate_notes.outputs.changelog }}"
# - name: Push New Tag
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# git tag ${{ env.new_tag }}
# git push origin ${{ env.new_tag }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Create GitHub Release
# uses: actions/create-release@v1
# with:
# tag_name: ${{ env.new_tag }}
# release_name: "Release ${{ env.new_tag }}"
# body: ${{ steps.generate_notes.outputs.changelog }}
# draft: false
# prerelease: false
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}