2021-10-23 09:56:11 +00:00
name : Release milestone
2022-07-15 12:08:29 +00:00
description : Creates a release and tag out of a given milestone
2021-10-23 09:56:11 +00:00
inputs :
milestone :
description : Milestone for this release
required : true
github_token :
description : Secret GitHub token
required : true
runs :
using : composite
steps :
- name : Setup node
2024-03-15 21:03:10 +00:00
uses : actions/setup-node@v4
2021-10-23 09:56:11 +00:00
with :
node-version : '16'
2023-01-28 10:58:45 +00:00
- name : Setup git
shell : bash
env :
GITHUB_TOKEN : ${{ inputs.github_token }}
run : |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name : Get current date
id : date
uses : Kaven-Universe/github-action-current-date-time@v1
with :
format : 'YYYY-MM-DD'
2024-09-14 23:23:35 +00:00
- name : Get current major version number
id : majorvers
2024-09-20 19:49:35 +00:00
uses : azarc-io/regex-property-action@master
2023-01-28 10:58:45 +00:00
env :
MILESTONE : ${{ inputs.milestone }}
with :
value : ${{ env.MILESTONE }}
2024-09-14 23:23:35 +00:00
regex : (\d+)\.\d+\.\d+
2023-01-30 11:57:11 +00:00
replacement : "$1"
2024-09-20 19:49:35 +00:00
- name : Get current minor version number
id : minorvers
uses : azarc-io/regex-property-action@master
2023-07-27 15:47:36 +00:00
env :
MILESTONE : ${{ inputs.milestone }}
with :
value : ${{ env.MILESTONE }}
2024-09-20 19:49:35 +00:00
regex : \d+\.(\d+)\.\d+
replacement : "$1"
2023-07-27 15:47:36 +00:00
2024-09-20 19:49:35 +00:00
- name : Get current patch version number
id : patchvers
uses : azarc-io/regex-property-action@master
2023-01-30 11:57:11 +00:00
env :
MILESTONE : ${{ inputs.milestone }}
with :
value : ${{ env.MILESTONE }}
2024-09-20 19:49:35 +00:00
regex : \d+\.\d+\.(\d+)
replacement : "$1"
- name : Get current padded patch version number
id : paddedpatchvers
shell : bash
run : |
NUM=$(printf "%03d" ${{ steps.patchvers.outputs.value }})
echo "value=$NUM" >> $GITHUB_OUTPUT
2023-01-28 10:58:45 +00:00
- name : Get next version number
id : nextvers
uses : WyriHaximus/github-action-next-semvers@v1
env :
MILESTONE : ${{ inputs.milestone }}
with :
version : ${{ env.MILESTONE }}
2021-10-23 09:56:11 +00:00
- name : Close milestone
2023-05-27 22:16:26 +00:00
uses : Akkjon/close-milestone@v2.1.0
2023-01-30 15:54:17 +00:00
continue-on-error : true
2021-10-23 09:56:11 +00:00
env :
MILESTONE : ${{ inputs.milestone }}
GITHUB_TOKEN : ${{ inputs.github_token }}
2023-01-28 10:58:45 +00:00
with :
milestone_name : ${{ env.MILESTONE }}
2021-10-23 09:56:11 +00:00
2023-01-28 10:58:45 +00:00
- name : Create temporary tag
2021-10-23 09:56:11 +00:00
shell : bash
env :
MILESTONE : ${{ inputs.milestone }}
GITHUB_TOKEN : ${{ inputs.github_token }}
run : |
2023-01-30 11:57:11 +00:00
git tag --message "" "$MILESTONE" || true
git push origin "$MILESTONE" || true
git tag --force --message "" "$MILESTONE"
git push --force origin "$MILESTONE"
2021-10-23 09:56:11 +00:00
2023-01-28 10:58:45 +00:00
- name : Update generator version
2021-10-23 09:56:11 +00:00
shell : bash
env :
MILESTONE : ${{ inputs.milestone }}
2023-01-28 10:58:45 +00:00
run : |
echo -n "$MILESTONE" > layouts/partials/version.txt
2024-09-20 19:49:35 +00:00
- name : Generate english releasenotes
2023-01-28 10:58:45 +00:00
shell : bash
env :
2024-09-20 19:49:35 +00:00
MILESTONE : ${{ inputs.milestone }}
2021-10-23 09:56:11 +00:00
GITHUB_TOKEN : ${{ inputs.github_token }}
GREN_GITHUB_TOKEN : ${{ inputs.github_token }}
run : |
2024-09-29 21:54:17 +00:00
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}\"\ntype = \"releasenotes\"\nweight = -${{ steps.majorvers.outputs.value }}\n+++\n\n{{% pages showhidden=\"true\" showdivider=\"true\" %}}" > exampleSite/content/introduction/releasenotes/${{ steps.majorvers.outputs.value }}/_index.en.md
2023-01-28 10:58:45 +00:00
2024-09-20 19:49:35 +00:00
- name : Update releasenotes front matter
uses : surahmansada/file-regex-replace@v1
with :
regex : '(\ntitle = "Version )\d+\.\d+("\n.*\nweight = -)\d+(\n)'
2024-10-13 16:57:28 +00:00
replacement : "$1${{ steps.majorvers.outputs.value }}.${{ steps.minorvers.outputs.value }}$2${{ steps.minorvers.outputs.value }}$3"
2024-09-29 21:54:17 +00:00
include : exampleSite/content/introduction/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.en.md
2024-09-20 19:49:35 +00:00
- name : Update releasenotes heading
uses : surahmansada/file-regex-replace@v1
with :
regex : '(.)[\n\r\s]*[\n\r]+##\s+.*?[\n\r][\n\r\s]*(.)'
replacement : "$1\n\n## ${{ steps.majorvers.outputs.value }}.${{ steps.minorvers.outputs.value }}.0 (${{ steps.date.outputs.time }}) {#${{ steps.majorvers.outputs.value }}-${{ steps.minorvers.outputs.value }}-0}\n\n$2"
2024-09-29 21:54:17 +00:00
include : exampleSite/content/introduction/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.en.md
2024-09-20 19:49:35 +00:00
- name : Generate piratish releasenotes
shell : bash
run : |
2024-09-29 21:54:17 +00:00
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}\"\ntype = \"releasenotes\"\nweight = -${{ steps.majorvers.outputs.value }}\n+++\n{{< piratify >}}" > exampleSite/content/introduction/releasenotes/${{ steps.majorvers.outputs.value }}/_index.pir.md
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}.${{ steps.minorvers.outputs.value }}\"\ntype = \"releasenotes\"\nweight = -${{ steps.minorvers.outputs.value }}\n+++\n{{< piratify >}}" > exampleSite/content/introduction/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.pir.md
2024-09-20 19:49:35 +00:00
- name : Generate english changelogs
2023-01-28 10:58:45 +00:00
shell : bash
env :
MILESTONE : ${{ inputs.milestone }}
GITHUB_TOKEN : ${{ inputs.github_token }}
GREN_GITHUB_TOKEN : ${{ inputs.github_token }}
2024-09-20 19:49:35 +00:00
run : |
2024-09-29 21:54:17 +00:00
mkdir -p exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}\"\ntype = \"changelog\"\nweight = -${{ steps.majorvers.outputs.value }}\n+++\n\n{{% pages showhidden=\"true\" showdivider=\"true\" %}}" > exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/_index.en.md
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}.${{ steps.minorvers.outputs.value }}\"\ntype = \"changelog\"\nweight = -${{ steps.minorvers.outputs.value }}\n+++\n\n{{% pages showhidden=\"true\" showdivider=\"true\" reverse=\"true\" %}}" > exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/_index.en.md
npx github-release-notes@0.17.1 changelog --generate --changelog-filename exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/${{ steps.paddedpatchvers.outputs.value }}.en.md --tags "$MILESTONE"
2024-09-20 19:49:35 +00:00
- name : Generate piratish changelogs
shell : bash
run : |
2024-09-29 21:54:17 +00:00
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}\"\ntype = \"changelog\"\nweight = -${{ steps.majorvers.outputs.value }}\n+++\n{{< piratify >}}" > exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/_index.pir.md
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}.${{ steps.minorvers.outputs.value }}\"\ntype = \"changelog\"\nweight = -${{ steps.minorvers.outputs.value }}\n+++\n{{< piratify >}}" > exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/_index.pir.md
echo -e "+++\n+++\n{{< piratify >}}" > exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/${{ steps.paddedpatchvers.outputs.value }}.pir.md
2024-09-20 19:49:35 +00:00
- name : Read changelog
id : changelog_docs
uses : guibranco/github-file-reader-action-v2@latest
with :
2024-09-29 21:54:17 +00:00
path : exampleSite/content/introduction/changelog/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/${{ steps.paddedpatchvers.outputs.value }}.en.md
2024-09-20 19:49:35 +00:00
- name : Write changelog to CHANGELOG.md
uses : surahmansada/file-regex-replace@v1
with :
regex : '(##\s+.*?[\n\r])[\n\r\s]*([\s\S]*)'
replacement : "${{ steps.changelog_docs.outputs.contents }}\n---\n\n$1\n$2"
include : CHANGELOG.md
- name : Set changelog for GitHub release
id : changelog_github
uses : azarc-io/regex-property-action@master
with :
value : ${{ steps.changelog_docs.outputs.contents }}
regex : '(##\s+.*?[\n\r])[\n\r\s]*([\s\S]*)'
2024-09-29 21:54:17 +00:00
replacement : "[★ What's new in this version ★](https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/)\n\n$2"
2024-09-20 19:49:35 +00:00
- name : Commit updates
shell : bash
env :
MILESTONE : ${{ inputs.milestone }}
GITHUB_TOKEN : ${{ inputs.github_token }}
2023-01-28 10:58:45 +00:00
run : |
2021-10-23 09:56:11 +00:00
git add *
git commit --message "Ship tag $MILESTONE"
git push origin main
2024-09-20 19:49:35 +00:00
- name : Create final tags
2021-10-23 09:56:11 +00:00
shell : bash
env :
MILESTONE : ${{ inputs.milestone }}
2023-01-30 11:57:11 +00:00
MILESTONE_MAJOR : ${{ steps.majorvers.outputs.value }}
2024-09-20 19:49:35 +00:00
MILESTONE_MINOR : ${{ steps.minorvers.outputs.value }}
2021-10-23 09:56:11 +00:00
GITHUB_TOKEN : ${{ inputs.github_token }}
run : |
2023-01-30 11:57:11 +00:00
git tag --force --message "" "$MILESTONE"
2021-10-23 09:56:11 +00:00
git push --force origin "$MILESTONE"
2024-09-20 19:49:35 +00:00
git tag --message "" "$MILESTONE_MAJOR.$MILESTONE_MINOR.x" || true
git push origin "$MILESTONE_MAJOR.$MILESTONE_MINOR.x" || true
git tag --force --message "" "$MILESTONE_MAJOR.$MILESTONE_MINOR.x"
git push --force origin "$MILESTONE_MAJOR.$MILESTONE_MINOR.x"
2023-01-30 11:57:11 +00:00
git tag --message "" "$MILESTONE_MAJOR.x" || true
git push origin "$MILESTONE_MAJOR.x" || true
git tag --force --message "" "$MILESTONE_MAJOR.x"
git push --force origin "$MILESTONE_MAJOR.x"
2023-02-05 12:01:49 +00:00
git tag --message "" "x" || true
git push origin "x" || true
git tag --force --message "" "x"
git push --force origin "x"
2021-10-23 09:56:11 +00:00
- name : Publish release
2024-09-20 19:49:35 +00:00
uses : ncipollo/release-action@v1
2021-10-23 09:56:11 +00:00
env :
MILESTONE : ${{ inputs.milestone }}
2024-09-20 19:49:35 +00:00
GITHUB_TOKEN : ${{ inputs.github_token }}
with :
body : |
${{ steps.changelog_github.outputs.value }}
tag : ${{ env.MILESTONE }}
2022-02-11 08:38:19 +00:00
2022-07-15 12:08:29 +00:00
- name : Create next patch milestone
2023-01-04 00:19:49 +00:00
uses : WyriHaximus/github-action-create-milestone@v1
2023-01-30 15:54:17 +00:00
continue-on-error : true
2022-07-15 12:08:29 +00:00
env :
GITHUB_TOKEN : ${{ inputs.github_token }}
2023-01-28 10:58:45 +00:00
with :
title : ${{ steps.nextvers.outputs.patch }}