Skip to content

Release

Release #20

Workflow file for this run

---
name: Release
on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *"
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Generate Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Get Previous Release Tag and Determine Next Tag
id: determine-next-tag
uses: actions/github-script@v7
with:
github-token: "${{ steps.app-token.outputs.token }}"
result-encoding: string
script: |
const { data: releases } = await github.rest.repos.listTags({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
});
let previousTag = "0.0.0"; // Default if no previous release exists
if (releases.length > 0) {
previousTag = releases[0].tag_name;
}
const [previousMajor, previousMinor, previousPatch] = previousTag.split('.').map(Number);
const currentYear = new Date().getFullYear();
const currentMonth = new Date().getMonth() + 1; // Months are 0-indexed in JavaScript
const nextMajorMinor = `${currentYear}.${currentMonth}`;
let nextPatch;
if (`${previousMajor}.${previousMinor}` === nextMajorMinor) {
console.log("Month release already exists for the year. Incrementing patch number by 1.");
nextPatch = previousPatch + 1;
} else {
console.log("Month release does not exist for the year. Starting with patch number 0.");
nextPatch = 0;
}
return `${nextMajorMinor}.${nextPatch}`;
- name: Create Release
uses: actions/github-script@v7
with:
github-token: "${{ steps.app-token.outputs.token }}"
script: |
const releaseTag = ${{ steps.determine-next-tag.outputs.result }};
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: releaseTag,
name: releaseTag,
generate_release_notes: true,
});