From e47589096dd2085aabd723683e39d5af396f6c22 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Fri, 1 Nov 2024 19:39:58 +0000 Subject: [PATCH 01/12] Add a workflow for checking issue versions --- .github/workflows/bug-report-version.yml | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/bug-report-version.yml diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml new file mode 100644 index 0000000..ce4b70b --- /dev/null +++ b/.github/workflows/bug-report-version.yml @@ -0,0 +1,73 @@ +name: Bug Report Version Check +on: + issues: + types: [opened] + +jobs: + check-bug-report: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Read Bloxstrap version from .csproj + id: read-version + run: | + version=$(grep -oPm1 "(?<=)[^<]+" Bloxstrap.csproj) + echo "::set-output name=version::$version" + + - name: Check issue body for Bloxstrap version + uses: actions/github-script@v7 + id: check-issue + with: + script: | + const issueBody = context.payload.issue.body; + const versionHeader = issueBody.match(/### Bloxstrap Version/); + const versionMatch = issueBody.match(/v\d+\.\d+\.\d+/); + const latestVersion = '${{ steps.read-version.outputs.version }}'; + + if (!versionHeader) { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Please include the "### Bloxstrap Version" header in your bug report.' + }); + return github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' + }); + } + + if (!versionMatch) { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Please specify the Bloxstrap version you are using.' + }); + return github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' + }); + } + + const issueVersion = versionMatch[0]; + if (issueVersion !== latestVersion) { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the latest version (${latestVersion}).` + }); + return github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' + }); + } \ No newline at end of file From 74733e8d9e5909db2fa8a349be4f7ad912145f24 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Fri, 1 Nov 2024 19:44:25 +0000 Subject: [PATCH 02/12] Fix version getting --- .github/workflows/bug-report-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index ce4b70b..0d9c556 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -13,7 +13,7 @@ jobs: - name: Read Bloxstrap version from .csproj id: read-version run: | - version=$(grep -oPm1 "(?<=)[^<]+" Bloxstrap.csproj) + version=$(grep -oPm1 "(?<=)[^<]+" Bloxstrap/Bloxstrap.csproj) echo "::set-output name=version::$version" - name: Check issue body for Bloxstrap version From fa5e00d6ec145cae7ba1d289af7e6aea5985eee0 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Fri, 1 Nov 2024 19:52:06 +0000 Subject: [PATCH 03/12] Add test workflow --- .github/workflows/bug-report-version.yml | 71 +++--------------------- 1 file changed, 8 insertions(+), 63 deletions(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index 0d9c556..0768c47 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -4,70 +4,15 @@ on: types: [opened] jobs: - check-bug-report: + comment: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Read Bloxstrap version from .csproj - id: read-version - run: | - version=$(grep -oPm1 "(?<=)[^<]+" Bloxstrap/Bloxstrap.csproj) - echo "::set-output name=version::$version" - - - name: Check issue body for Bloxstrap version - uses: actions/github-script@v7 - id: check-issue + - uses: actions/github-script@v7 with: script: | - const issueBody = context.payload.issue.body; - const versionHeader = issueBody.match(/### Bloxstrap Version/); - const versionMatch = issueBody.match(/v\d+\.\d+\.\d+/); - const latestVersion = '${{ steps.read-version.outputs.version }}'; - - if (!versionHeader) { - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Please include the "### Bloxstrap Version" header in your bug report.' - }); - return github.rest.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state: 'closed' - }); - } - - if (!versionMatch) { - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Please specify the Bloxstrap version you are using.' - }); - return github.rest.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state: 'closed' - }); - } - - const issueVersion = versionMatch[0]; - if (issueVersion !== latestVersion) { - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the latest version (${latestVersion}).` - }); - return github.rest.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state: 'closed' - }); - } \ No newline at end of file + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '👋 Thanks for reporting!' + }) \ No newline at end of file From 08377f924ec70d390a8d67fe66487fa775bef59b Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:15:08 +0000 Subject: [PATCH 04/12] Add draft --- .github/workflows/bug-report-version.yml | 50 +++++++++++++++++++----- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index 0768c47..2a44668 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -1,18 +1,50 @@ -name: Bug Report Version Check +name: Check Bug Report Version on: issues: types: [opened] jobs: - comment: + check-version: runs-on: ubuntu-latest + steps: - - uses: actions/github-script@v7 + - uses: actions/checkout@v4 + + - name: Get latest version + id: read-version + run: | + version=$(grep -oPm1 "(?<=)[^<]+" Bloxstrap/Bloxstrap.csproj) + echo "::set-output name=version::$version" + + - name: Check issue for Bloxstrap version + uses: actions/github-script@v7 + id: check-issue with: script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '👋 Thanks for reporting!' - }) \ No newline at end of file + const issueBody = context.payload.issue.body; + const versionHeader = issueBody.match(/### Bloxstrap Version/); + const versionMatch = issueBody.match(/v\d+\.\d+\.\d+/); + const latestVersion = '${{ steps.read-version.outputs.version }}'; + if (versionHeader && !versionMatch) { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Unable to find Bloxstrap version.' + }); + } + const issueVersion = versionMatch[0]; + if (issueVersion !== latestVersion) { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the [latest version of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest) (${latestVersion}).` + }); + return github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' + }); + } \ No newline at end of file From ff3e1c1cda704bf149f8c096014d5d816f15c61b Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:18:27 +0000 Subject: [PATCH 05/12] Fix error when evaluating --- .github/workflows/bug-report-version.yml | 28 ++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index 2a44668..d72e8ea 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -25,26 +25,22 @@ jobs: const versionHeader = issueBody.match(/### Bloxstrap Version/); const versionMatch = issueBody.match(/v\d+\.\d+\.\d+/); const latestVersion = '${{ steps.read-version.outputs.version }}'; + if (versionHeader && !versionMatch) { await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: 'Unable to find Bloxstrap version.' - }); - } - const issueVersion = versionMatch[0]; - if (issueVersion !== latestVersion) { - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the [latest version of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest) (${latestVersion}).` - }); - return github.rest.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state: 'closed' + body: 'Please specify the Bloxstrap version you are using.' }); + } else if (versionMatch) { + const issueVersion = versionMatch[0]; + if (issueVersion !== latestVersion) { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the [latest version of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest) (${latestVersion}).` + }); + } } \ No newline at end of file From 0bd48993ee8bc64efa61c5c8490ac87a61c56f15 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:24:38 +0000 Subject: [PATCH 06/12] Upgrade to using Environment Files --- .github/workflows/bug-report-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index d72e8ea..d5e4e42 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -14,7 +14,7 @@ jobs: id: read-version run: | version=$(grep -oPm1 "(?<=)[^<]+" Bloxstrap/Bloxstrap.csproj) - echo "::set-output name=version::$version" + echo "version=$version" >> $GITHUB_OUTPUT - name: Check issue for Bloxstrap version uses: actions/github-script@v7 From 4cde20da93971b7ad8dc739d0315a2d3e307beb3 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:25:01 +0000 Subject: [PATCH 07/12] Update match pattern --- .github/workflows/bug-report-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index d5e4e42..35ee1c3 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -23,7 +23,7 @@ jobs: script: | const issueBody = context.payload.issue.body; const versionHeader = issueBody.match(/### Bloxstrap Version/); - const versionMatch = issueBody.match(/v\d+\.\d+\.\d+/); + const versionMatch = issueBody.match(/v?\d+\.\d+\.\d+/); const latestVersion = '${{ steps.read-version.outputs.version }}'; if (versionHeader && !versionMatch) { From 971ccf994d7f82367b62999ac992c073872b0fea Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:34:01 +0000 Subject: [PATCH 08/12] Add notice on what format to use --- .github/workflows/bug-report-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index 35ee1c3..3f938db 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -31,7 +31,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: 'Please specify the Bloxstrap version you are using.' + body: 'Please specify the Bloxstrap version you are using. Use the format `vX.Y.Z`.' }); } else if (versionMatch) { const issueVersion = versionMatch[0]; From 5f79605a0094670927cd79f85f31cb9f30f4e454 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:34:12 +0000 Subject: [PATCH 09/12] Add reopen issue statement --- .github/workflows/bug-report-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index 3f938db..b988568 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -40,7 +40,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the [latest version of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest) (${latestVersion}).` + body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the [latest version of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest). If you are still experiencing the bug, please reopen this issue.` }); } } \ No newline at end of file From c37f46b3ddb344c62266b63c5642a683db6532aa Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:38:17 +0000 Subject: [PATCH 10/12] Close issue on outdated version --- .github/workflows/bug-report-version.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index b988568..ce7a6e3 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -42,5 +42,11 @@ jobs: repo: context.repo.repo, body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the [latest version of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest). If you are still experiencing the bug, please reopen this issue.` }); + return github.rest.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' + }); } } \ No newline at end of file From 9d638b42846cbf465f8736a7e22fa0009b1c1273 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Sun, 3 Nov 2024 20:40:19 +0000 Subject: [PATCH 11/12] Close as not planned --- .github/workflows/bug-report-version.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index ce7a6e3..62d3526 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -46,7 +46,8 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - state: 'closed' + state: 'closed', + state_reason: 'not_planned' }); } } \ No newline at end of file From d243a88b384972ed767ea9c3b25ef8e1ba825a4b Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Thu, 2 Jan 2025 00:47:36 -0800 Subject: [PATCH 12/12] Allow commas --- .github/workflows/bug-report-version.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bug-report-version.yml b/.github/workflows/bug-report-version.yml index 62d3526..d2fa013 100644 --- a/.github/workflows/bug-report-version.yml +++ b/.github/workflows/bug-report-version.yml @@ -23,7 +23,7 @@ jobs: script: | const issueBody = context.payload.issue.body; const versionHeader = issueBody.match(/### Bloxstrap Version/); - const versionMatch = issueBody.match(/v?\d+\.\d+\.\d+/); + const versionMatch = issueBody.match(/v?\d+[\.,]\d+[\.,]\d+/); const latestVersion = '${{ steps.read-version.outputs.version }}'; if (versionHeader && !versionMatch) { @@ -50,4 +50,4 @@ jobs: state_reason: 'not_planned' }); } - } \ No newline at end of file + }