build: adapt to new structure #917

This commit is contained in:
Sören Weber 2024-09-20 21:49:35 +02:00
parent 997e5c41d6
commit 6d3ef8d537
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
5 changed files with 138 additions and 77 deletions

View file

@ -23,7 +23,7 @@ runs:
with:
query: |
query {
search(first: 1, type: ISSUE, query: "user:${{ github.repository_owner }} repo:${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:closed") {
search(first: 1, type: ISSUE, query: "repo:${{ github.repository_owner }}/${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:closed") {
issueCount
}
}
@ -37,36 +37,34 @@ runs:
with:
query: |
query {
search(first: 1, type: ISSUE, query: "user:${{ github.repository_owner }} repo:${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:open") {
search(first: 1, type: ISSUE, query: "repo:${{ github.repository_owner }}/${{ github.event.repository.name }} milestone:${{ env.MILESTONE }} state:open") {
issueCount
}
}
- name: Get old version number
id: oldvers
uses: andstor/file-reader-action@v1
- name: Get current major version number
id: majorvers
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
with:
path: layouts/partials/version.txt
value: ${{ env.MILESTONE }}
regex: (\d+)\.\d+\.\d+
replacement: "$1"
- name: Get old major version number
id: oldmajorvers
uses: ashley-taylor/regex-property-action@v1
- name: Get current minor version number
id: minorvers
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
with:
value: ${{ steps.oldvers.outputs.contents }}
regex: (\d+)\.\d+\.\d+.*
replacement: '$1'
- name: Get old main version number
id: oldmainvers
uses: ashley-taylor/regex-property-action@v1
with:
value: ${{ steps.oldvers.outputs.contents }}
regex: (\d+)\.(\d+)\.\d+.*
replacement: '$1\.$2'
value: ${{ env.MILESTONE }}
regex: \d+\.(\d+)\.\d+
replacement: "$1"
- name: Get current patch version number
id: patchvers
uses: ashley-taylor/regex-property-action@v1
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
with:
@ -74,26 +72,25 @@ runs:
regex: \d+\.\d+\.(\d+)
replacement: "$1"
- name: Get releasenotes
- name: Check if releasenotes exists
id: releasenotes
uses: andstor/file-reader-action@v1
with:
path: exampleSite/content/basics/releasenotes/${{ steps.oldmajorvers.outputs.value }}.x/_index.en.md
- name: Check for old releasenotes
id: hasoldnotes
uses: ashley-taylor/regex-property-action@v1
with:
value: ${{ steps.releasenotes.outputs.contents }}
regex: '.*?[\n\r\s]*<!--GH-ACTION-RELEASE-MILESTONE-->[\n\r\s]*[\n\r]+##\s+${{ steps.oldmainvers.outputs.value }}\.0\s+.*?[\n\r][\n\r\s]*.*'
flags: gs
replacement: '1'
shell: bash
run: |
if [ -f "exampleSite/content/basics/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.en.md" ]; then
echo "file_exists=true" >> $GITHUB_OUTPUT
else
echo "file_exists=false" >> $GITHUB_OUTPUT
fi
- name: Set outcome
id: outcome
shell: bash
run: |
if [ "${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount > 0 && fromJSON(steps.open_issues.outputs.data).search.issueCount == 0 && ( (steps.patchvers.outputs.value!='0'&&steps.hasoldnotes.outputs.value=='1') || (steps.patchvers.outputs.value=='0'&&steps.hasoldnotes.outputs.value!='1') ) }}" = "true" ]; then
if [[ \
${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount }} -gt 0 && \
${{ fromJSON(steps.open_issues.outputs.data).search.issueCount }} -eq 0 && \
${{ steps.releasenotes.outputs.file_exists == 'true' }} \
]]; then
echo "outcome=success" >> $GITHUB_OUTPUT
else
echo "outcome=failure" >> $GITHUB_OUTPUT
@ -102,12 +99,12 @@ runs:
- name: Log results and exit
shell: bash
run: |
echo outcome : ${{ steps.outcome.outputs.outcome }}
echo has closed issues : ${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount > 0 }}
echo has open issues : ${{ fromJSON(steps.open_issues.outputs.data).search.issueCount > 0 }}
echo is patch version : ${{ steps.patchvers.outputs.value != '0' }}
echo has old releasenotes : ${{ steps.hasoldnotes.outputs.value == '1' }}
echo are notes okay : ${{ (steps.patchvers.outputs.value!='0'&&steps.hasoldnotes.outputs.value=='1') || (steps.patchvers.outputs.value=='0'&&steps.hasoldnotes.outputs.value!='1') }}
echo outcome : ${{ steps.outcome.outputs.outcome }}
echo has closed issues : ${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount > 0 }}
echo count : ${{ fromJSON(steps.closed_issues.outputs.data).search.issueCount }}
echo has all issues closed : ${{ fromJSON(steps.open_issues.outputs.data).search.issueCount == 0 }}
echo count : ${{ fromJSON(steps.open_issues.outputs.data).search.issueCount }}
echo has releasenotes : ${{ steps.releasenotes.outputs.file_exists }}
if [ "${{ steps.outcome.outputs.outcome }}" = "failure" ]; then
exit 1
fi

View file

@ -31,7 +31,7 @@ runs:
- name: Get current major version number
id: majorvers
uses: ashley-taylor/regex-property-action@v1
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
with:
@ -39,25 +39,32 @@ runs:
regex: (\d+)\.\d+\.\d+
replacement: "$1"
- name: Get current main version number
id: mainvers
uses: ashley-taylor/regex-property-action@v1
- name: Get current minor version number
id: minorvers
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
with:
value: ${{ env.MILESTONE }}
regex: (\d+)\.(\d+)\.\d+
replacement: "$1.$2"
regex: \d+\.(\d+)\.\d+
replacement: "$1"
- name: Get current main version number for anchoring
id: mainanchor
uses: ashley-taylor/regex-property-action@v1
- name: Get current patch version number
id: patchvers
uses: azarc-io/regex-property-action@master
env:
MILESTONE: ${{ inputs.milestone }}
with:
value: ${{ env.MILESTONE }}
regex: (\d+)\.(\d+)\.\d+
replacement: "$1$2"
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
- name: Get next version number
id: nextvers
@ -87,13 +94,6 @@ runs:
git tag --force --message "" "$MILESTONE"
git push --force origin "$MILESTONE"
- name: Update releasenotes
uses: mingjun97/file-regex-replace@v1
with:
regex: '(.)[\n\r\s]*<!--GH-ACTION-RELEASE-MILESTONE-->[\n\r\s]*[\n\r]+##\s*.*?[\n\r][\n\r\s]*(.)'
replacement: "$1\n\n<!--GH-ACTION-RELEASE-MILESTONE-->\n\n## ${{ steps.mainvers.outputs.value }}.0 (${{ steps.date.outputs.time }}) {#${{ steps.mainanchor.outputs.value }}0}\n\n$2"
include: exampleSite/content/basics/releasenotes/${{ steps.majorvers.outputs.value }}.x/_index.en.md
- name: Update generator version
shell: bash
env:
@ -101,39 +101,99 @@ runs:
run: |
echo -n "$MILESTONE" > layouts/partials/version.txt
- name: Update changelog
- name: Generate english releasenotes
shell: bash
env:
MILESTONE: ${{ inputs.milestone }}
GITHUB_TOKEN: ${{ inputs.github_token }}
GREN_GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
npx github-release-notes@0.17.1 changelog --generate --override --tags=all
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\" reverse="true" %}}\n" > exampleSite/content/basics/releasenotes/${{ steps.majorvers.outputs.value }}/_index.en.md
- name: Update releasenotes front matter
uses: surahmansada/file-regex-replace@v1
with:
regex: '(\ntitle = "Version )\d+\.\d+("\n.*\nweight = -)\d+(\n)'
replacement: "$1${{ steps.majorvers.outputs.value }}.${{ steps.minorvers.outputs.value }}.0$2${{ steps.minorvers.outputs.value }}$3"
include: exampleSite/content/basics/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.en.md
- 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"
include: exampleSite/content/basics/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.en.md
- name: Generate piratish releasenotes
shell: bash
run: |
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}\"\ntype = \"releasenotes\"\nweight = -${{ steps.majorvers.outputs.value }}\n+++\n{{< piratify true >}}" > exampleSite/content/basics/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 true >}}" > exampleSite/content/basics/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}.pir.md
- name: Generate english changelogs
shell: bash
env:
MILESTONE: ${{ inputs.milestone }}
GITHUB_TOKEN: ${{ inputs.github_token }}
GREN_GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
mkdir -p exampleSite/content/basics/history/${{ 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\" %}}\n" > exampleSite/content/basics/history/${{ 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\" %}}\n" > exampleSite/content/basics/history/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/_index.en.md
npx github-release-notes@0.17.1 changelog --generate --changelog-filename exampleSite/content/basics/history/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/${{ steps.paddedpatchvers.outputs.value }}.en.md --tags "$MILESTONE"
- name: Generate piratish changelogs
shell: bash
run: |
echo -e "+++\ndisableToc = false\nhidden = true\ntitle = \"Version ${{ steps.majorvers.outputs.value }}\"\ntype = \"changelog\"\nweight = -${{ steps.majorvers.outputs.value }}\n+++\n{{< piratify true >}}" > exampleSite/content/basics/history/${{ 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 true >}}" > exampleSite/content/basics/history/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/_index.pir.md
echo -e "+++\n+++\n{{< piratify true >}}" > exampleSite/content/basics/history/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/${{ steps.paddedpatchvers.outputs.value }}.pir.md
- name: Read changelog
id: changelog_docs
uses: guibranco/github-file-reader-action-v2@latest
with:
path: exampleSite/content/basics/history/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/${{ steps.paddedpatchvers.outputs.value }}.en.md
- 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]*)'
replacement: "[★ Whats new in this version ★](https://mcshelby.github.io/hugo-theme-relearn/basics/releasenotes/${{ steps.majorvers.outputs.value }}/${{ steps.minorvers.outputs.value }}/)\n\n$2"
- name: Commit updates
shell: bash
env:
MILESTONE: ${{ inputs.milestone }}
GITHUB_TOKEN: ${{ inputs.github_token }}
GREN_GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
git add *
git commit --message "Ship tag $MILESTONE"
git push origin main
- name: Create final tag
- name: Create final tags
shell: bash
env:
MILESTONE: ${{ inputs.milestone }}
MILESTONE_MINOR: ${{ steps.mainvers.outputs.value }}
MILESTONE_MAJOR: ${{ steps.majorvers.outputs.value }}
MILESTONE_MINOR: ${{ steps.minorvers.outputs.value }}
GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
git tag --force --message "" "$MILESTONE"
git push --force origin "$MILESTONE"
git tag --message "" "$MILESTONE_MINOR.x" || true
git push origin "$MILESTONE_MINOR.x" || true
git tag --force --message "" "$MILESTONE_MINOR.x"
git push --force origin "$MILESTONE_MINOR.x"
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"
git tag --message "" "$MILESTONE_MAJOR.x" || true
git push origin "$MILESTONE_MAJOR.x" || true
git tag --force --message "" "$MILESTONE_MAJOR.x"
@ -144,12 +204,14 @@ runs:
git push --force origin "x"
- name: Publish release
shell: bash
uses: ncipollo/release-action@v1
env:
MILESTONE: ${{ inputs.milestone }}
GREN_GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
npx github-release-notes@0.17.1 release --tags "$MILESTONE"
GITHUB_TOKEN: ${{ inputs.github_token }}
with:
body: |
${{ steps.changelog_github.outputs.value }}
tag: ${{ env.MILESTONE }}
- name: Update version number to mark non-release version
shell: bash
@ -166,7 +228,6 @@ runs:
uses: WyriHaximus/github-action-create-milestone@v1
continue-on-error: true
env:
MILESTONE: ${{ inputs.milestone }}
GITHUB_TOKEN: ${{ inputs.github_token }}
with:
title: ${{ steps.nextvers.outputs.patch }}

View file

@ -44,7 +44,8 @@ module.exports = {
milestoneMatch: "{{tag_name}}",
onlyMilestones: true,
template: {
changelogTitle: "",
group: "\n### {{heading}}\n",
release: ({ body, date, release }) => `## ${release} (` + date.replace( /(\d+)\/(\d+)\/(\d+)/, '$3-$2-$1' ) + `)\n\n[★ What's new in this version ★](https://mcshelby.github.io/hugo-theme-relearn/basics/releasenotes/` + release.replace( /(\d+)\.(\d+)\.(\d+)/, '$1' ) + `/#` + release.replace( /(\d+)\.(\d+)\.(\d+)/, '$1-$2-0' ) + `)\n${body}`,
release: ({ body, date, release }) => `## ${release} (` + date.replace( /(\d+)\/(\d+)\/(\d+)/, '$3-$2-$1' ) + `)\n${body}`,
},
};

View file

@ -7,3 +7,4 @@ weight = -0
+++
{{% pages showhidden="true" showdivider="true" reverse="true" %}}

View file

@ -46,13 +46,14 @@ Many thanks to [Andy Miller](https://github.com/rhukster) for initially creating
- https://github.com/actions/checkout
- https://github.com/actions/setup-node
- https://github.com/Akkjon/close-milestone
- https://github.com/andstor/file-reader-action
- https://github.com/ashley-taylor/regex-property-action
- https://github.com/azarc-io/regex-property-action
- https://github.com/guibranco/github-file-reader-action-v2
- https://github.com/Kaven-Universe/github-action-current-date-time
- https://github.com/mingjun97/file-regex-replace
- https://github.com/octokit/graphql-action
- https://github.com/peaceiris/actions-gh-pages
- https://github.com/peaceiris/actions-hugo
https://github.com/ncipollo/release-action
- https://github.com/surahmansada/file-regex-replace
- https://github.com/WyriHaximus/github-action-create-milestone
- https://github.com/WyriHaximus/github-action-next-semvers
- [gren](https://github.com/github-tools/github-release-notes) - A releasenotes generator for GitHub