Release #5
This file contains 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
--- | |
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: "Release" | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 1 * *" # 1st of every month at midnight | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Get Previous Release Tag and Determine Next Tag | |
id: release-tag | |
uses: actions/[email protected] | |
with: | |
result-encoding: string | |
script: | | |
const { data: releases } = await github.rest.repos.listReleases({ | |
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: Release | |
uses: softprops/[email protected] | |
with: | |
generate_release_notes: true | |
tag_name: ${{ steps.release-tag.outputs.result }} |