Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧Improve prepare release process #189

Merged
merged 43 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a2db021
Start work for issue #172
CalvinWilkinson Dec 7, 2023
378cfd6
Merge branch 'main' into feature/172-improve-prep-release
CalvinWilkinson Dec 7, 2023
c140090
config: add deno tasks
CalvinWilkinson Dec 7, 2023
90920d3
refactor: refactor name of gaurd function
CalvinWilkinson Dec 7, 2023
4ec1458
refactor: improve regex related to versions
CalvinWilkinson Dec 7, 2023
b685005
chore: create custom type for project types
CalvinWilkinson Dec 8, 2023
31adb0f
chore: create base class for version services
CalvinWilkinson Dec 8, 2023
cde30c4
refactor: update csharp version service to use version service base
CalvinWilkinson Dec 8, 2023
790a719
feat: create a new service for updating versions in deno.json config …
CalvinWilkinson Dec 8, 2023
1555c52
feat: update prepare release runner to update deno versions
CalvinWilkinson Dec 8, 2023
3e334ea
ci: create prepare release workflow for testing prep release process
CalvinWilkinson Dec 8, 2023
6c5750c
config: add version to deno config file for testing purposes
CalvinWilkinson Dec 8, 2023
996ac38
ci: remove unnecessary message from prepare release workflow
CalvinWilkinson Dec 9, 2023
c662136
chore: remove redundant client instantiation
CalvinWilkinson Dec 9, 2023
8d1a718
deps: update kd_clients modules to latest version
CalvinWilkinson Dec 9, 2023
f78ef2f
deps: update deno lock
CalvinWilkinson Dec 9, 2023
59337f3
ci: update reusable workflow versions
CalvinWilkinson Dec 9, 2023
627bef9
fix: fix issue with adding pr to the project
CalvinWilkinson Dec 10, 2023
9e1f40a
chore: add process update messages
CalvinWilkinson Dec 10, 2023
82649e3
refactor: change process to update version by adding it if it doesn't…
CalvinWilkinson Dec 10, 2023
b1d863c
fix: fix issue with contains schema check
CalvinWilkinson Dec 11, 2023
50813b7
refactor: improve process of checking that the version already exists
CalvinWilkinson Dec 11, 2023
263cde7
chore: add ability to add a version if it does not exist at all
CalvinWilkinson Dec 11, 2023
c3a08a5
refactor: improve error message
CalvinWilkinson Dec 11, 2023
c862624
chore: improve get var value code
CalvinWilkinson Dec 11, 2023
03121f8
refactor: change function name
CalvinWilkinson Dec 11, 2023
e4b9552
deps: update deno lock
CalvinWilkinson Dec 11, 2023
4bd53ab
chore: change version for testing purposes
CalvinWilkinson Dec 11, 2023
4f4fe63
ide: fix issue with task
CalvinWilkinson Dec 11, 2023
f4fa756
fix: fix issue with commit message
CalvinWilkinson Dec 11, 2023
b71486d
chore: add new line chars to end of JSON string when adding new json key
CalvinWilkinson Dec 11, 2023
69ef183
ide: update launch config args
CalvinWilkinson Dec 11, 2023
d767406
chore: created script for testing the CSharpVersionService class
CalvinWilkinson Dec 11, 2023
0dbfea2
fix: update regex to properly match csproj data
CalvinWilkinson Dec 11, 2023
b07848e
refactor: improve error message
CalvinWilkinson Dec 11, 2023
530a540
chore: improve how already updated checks work
CalvinWilkinson Dec 11, 2023
2827e54
chore: improve closed by regex in status check runner
CalvinWilkinson Dec 11, 2023
874e74b
ci: improve workflow version status check regex
CalvinWilkinson Dec 11, 2023
2ec1a12
chore: improve version regex in utils class
CalvinWilkinson Dec 11, 2023
1463a6d
chore: update version regex in update workflow version script
CalvinWilkinson Dec 11, 2023
ee6cd66
ci: update reusable workflow versions
CalvinWilkinson Dec 11, 2023
f28843f
deps: update deno lock
CalvinWilkinson Dec 11, 2023
e011da7
ci: add deno permission to build status check
CalvinWilkinson Dec 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/internal-cicd/deno-tasks/clear-screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.clear();
10 changes: 10 additions & 0 deletions .github/internal-cicd/scripts/update-csharp-proj.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ReleaseType } from "../../../cicd/core/Enums.ts";
import { CSharpVersionService } from "../../../cicd/core/Services/CSharpVersionService.ts";

const _version = Deno.args[0].trim();
const _token = Deno.args[1].trim();

const service = new CSharpVersionService("KinsonDigital", "Infrastructure", _token);

await service.updateVersion(_version, ReleaseType.preview);

4 changes: 2 additions & 2 deletions .github/internal-cicd/scripts/update-workflow-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (!Directory.Exists(baseDirPath)) {
// Clear the console so the token is not visible from the tasks.json file
console.clear();

const tagRegex = /v[0-9]+\.[0-9]+\.[0-9]+/gm;
const tagRegex = /v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?/gm;

const newVersion = await Input.prompt({
message: chalk.blue("Enter version to upgrade workflows to:"),
Expand Down Expand Up @@ -57,7 +57,7 @@ if (allTags.includes(newVersion)) {
Deno.exit(0);
}

const reusableWorkflowRegex = /uses: .+.(yml|yaml)@v[0-9]+\.[0-9]+\.[0-9]+/gm;
const reusableWorkflowRegex = /uses: .+.(yml|yaml)@v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?/gm;

const updateMsgs: string[] = [];
let noFilesUpdated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const latestTag = (await tagClient.getAllTags())[0].name;

const workflowsToUpdate: WorkflowToUpdate[] = [];

const reusableWorkflowRegex = /uses: .+.(yml|yaml)@v[0-9]+\.[0-9]+\.[0-9]+/gm;
const reusableWorkflowRegex = /uses: .+.(yml|yaml)@v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?/gm;

type WorkflowToUpdate = {
/**
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/add-new-item-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
add_new_item_to_project:
name: Add New Issue
needs: item_number
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v13.5.0
with:
org-name: "${{ vars.ORGANIZATION_NAME }}"
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-csharp-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
resolve_proj_file_path:
name: Resolving ${{ inputs.project-name }} Project File Path
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.5.0
with:
project-name: ${{ inputs.project-name }}
base-path: ${{ inputs.base-path }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-status-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:

- name: Run Build
run: |
deno run --allow-read --allow-run "./.github/internal-cicd/scripts/deno-check.ts";
deno run --allow-read --allow-run --allow-sys "./.github/internal-cicd/scripts/deno-check.ts";
10 changes: 5 additions & 5 deletions .github/workflows/dotnet-action-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
validate_version:
name: Validate Version
needs: [print_validate_workflow, validate_branch]
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -168,7 +168,7 @@ jobs:
validate_tag:
name: Validate Tag
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
validate_github_release:
name: GitHub Release Does Not Exist
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -218,7 +218,7 @@ jobs:
build_project:
name: Build Main Project (${{ inputs.project-name }})
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
runs-on: "${{ inputs.runs-on }}"
Expand All @@ -231,7 +231,7 @@ jobs:
run_tests:
name: Run Tests
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}Tests"
runs-on: "${{ inputs.runs-on }}"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/dotnet-lib-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:

validate_version:
name: Validate Version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -193,7 +193,7 @@ jobs:
validate_tag:
name: Validate Tag
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -205,7 +205,7 @@ jobs:
nuget_pkg_does_not_exist:
name: Validate NuGet Package Does Not Exist
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -214,7 +214,7 @@ jobs:
validate_milestone_status:
name: Validate Milestone Status
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -225,7 +225,7 @@ jobs:
validate_github_release:
name: GitHub Release Does Not Exist
needs: [validate_version]
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -236,7 +236,7 @@ jobs:
build_project:
name: Build Main Project
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}"
runs-on: "${{ inputs.runs-on }}"
Expand All @@ -249,7 +249,7 @@ jobs:
run_tests:
name: Run Tests
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.5.0
with:
project-name: "${{ inputs.project-name }}Tests"
runs-on: "${{ inputs.runs-on }}"
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/prepare-release-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 🚁Prepare Release Test
run-name: 🚁Prepare ${{ inputs.release-type }} Release Test (${{ inputs.release-version }})


defaults:
run:
shell: pwsh


on:
workflow_dispatch:
inputs:
release-type:
description: The type of release. Choose 'Preview' or 'Production'.
required: true
type: choice
options: [Preview, Production]
release-version:
required: true
description: The version of the release to prepare.
type: string


jobs:
print_validate_workflow:
name: Print & Validate Prepare Release Workflow
runs-on: ubuntu-latest
steps:
- name: Print Environment Variables
run: Get-ChildItem -Path Env:* | Sort-Object Name

- name: Validate Workflow Inputs
run: |
$releaseType = "${{ inputs.release-type }}".ToLower();

if ("${{ vars.PROJECT_NAME }}".Trim() -eq "") {
Write-Host "::error::The project name input cannot be empty.";
exit 1;
}


if ($releaseType -eq "") {
Write-Host "::error::The release type input cannot be empty.";
exit 1;
}


if ($releaseType -ne 'preview' -and $releaseType -ne 'production') {
Write-Host "::error::The release type input must be either 'Preview' or 'Production'.";
exit 1;
}

$releaseVersion = "${{ inputs.release-version }}".Trim().ToLower();

if ($releaseVersion -eq "") {
Write-Host "::error::The 'release-version' workflow input cannot be empty.";
exit 1;
}


$prodVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+";
$prevVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+";

# Verify that the version has valid syntax
if (($releaseVersion -match $prodVersionRegex) -or ($releaseVersion -match $prevVersionRegex)) {
Write-Host "::notice::The 'release-version' workflow input is valid.";
} else {
$versionSyntax = $releaseType == "production" ? "v#.#.#" : "v#.#.#-preview.#";
Write-Host "::error::The 'release-version' workflow input is not valid. Expected format: '$versionSyntax";
exit 1;
}


prepare_release:
name: Prepare ${{ inputs.release-type }} Release Of ${{ vars.PROJECT_NAME }}
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
project-name: "${{ vars.PROJECT_NAME }}"
release-type: "${{ inputs.release-type }}"
release-version: "${{ inputs.release-version }}"
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ jobs:
$scriptUrl = $scriptUrl.EndsWith("/") ? $scriptUrl.Substring(0, $scriptUrl.Length - 1) : $scriptUrl;
$scriptUrl = "$scriptUrl/prepare-release.ts";

Write-Host "::notice::NuGet Package Check Script URL: $scriptUrl";

<# Deno Args:
1. Organization name
2. Project name
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-csharp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
resolve_proj_file_path:
name: Resolving ${{ inputs.project-name }} Project File Path
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.5.0
with:
project-name: ${{ inputs.project-name }}
base-path: ${{ inputs.base-path }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sync-pr-to-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
if: |
github.event_name == 'pull_request_target' &&
!startsWith(github.head_ref, 'renovate/')
uses: KinsonDigital/Infrastructure/.github/workflows/initial-manual-sync.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/initial-manual-sync.yml@v13.5.0
with:
issue-or-pr-number: ${{ github.event.pull_request.number }}
sync-type: initial
Expand All @@ -35,7 +35,7 @@ jobs:
github.event_name == 'issue_comment' &&
github.event.issue.pull_request && github.event.issue.pull_request.url != null &&
contains(github.event.comment.body, '[run-sync]')
uses: KinsonDigital/Infrastructure/.github/workflows/initial-manual-sync.yml@v13.4.0
uses: KinsonDigital/Infrastructure/.github/workflows/initial-manual-sync.yml@v13.5.0
with:
issue-or-pr-number: ${{ github.event.issue.number }}
sync-type: manual
Expand Down
11 changes: 5 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@
],
"args": [
"KinsonDigital",
"CASL",
"Infrastructure",
"preview",
"v1.0.0-preview.15",
"v1.2.3-preview.4",
"${env:CICD_TOKEN}",
],
"attachSimplePort": 9229,
Expand Down Expand Up @@ -357,16 +357,15 @@
"name": "Update CSharp File",
"request": "launch",
"type": "node",
"program": "${workspaceFolder}/cicd/scripts/update-csharp-proj.ts",
"cwd": "${workspaceFolder}/cicd",
"program": "${workspaceFolder}/.github/internal-cicd/scripts/update-csharp-proj.ts",
"cwd": "${workspaceFolder}",
"runtimeArgs": [
"run",
"--inspect-wait",
"--allow-all"
],
"args": [
"${workspaceFolder}/cicd/test-data/sample-csharp-proj-file.csproj",
"v1.0.0-preview.1",
"v11.22.33-preview.44",
"${env:CICD_TOKEN}",
],
"attachSimplePort": 9229,
Expand Down
3 changes: 0 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"label": "clear-terminal",
"detail": "Clears the terminal.",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/.github/cicd"
},
"windows": {
"command": "cls"
},
Expand Down
10 changes: 5 additions & 5 deletions cicd/core/Guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ export class Guard {
* @param value The value to check.
* @returns True if the value is null, undefined, or empty, otherwise false.
*/
public static isNullOrEmptyOrUndefined<T>(
public static isNothing<T>(
value: undefined | null | string | T[] | object,
funcName = "",
paramName = "",
): void {
if (Utils.isNothing(value)) {
Utils.printAsGitHubError("The value is null, undefined, or empty.");
let errorMsg = "The value is null, undefined, or empty.";

if (funcName != "") {
console.log(`Function Name: ${funcName}`);
errorMsg += `\nFunction Name: ${funcName}`;
}

if (paramName != "") {
console.log(`Param Name: ${paramName}`);
errorMsg += `\nParam Name: ${paramName}`;
}

Deno.exit(1);
throw new Error(errorMsg);
}
}

Expand Down
10 changes: 5 additions & 5 deletions cicd/core/ReleaseTweetBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export class ReleaseTweetBuilder {
discordInviteCode: string,
): Promise<string> {
const funcName = "buildTweet";
Guard.isNullOrEmptyOrUndefined(branchName, funcName, "branchName");
Guard.isNullOrEmptyOrUndefined(relativeFilePath, funcName, "relativeFilePath");
Guard.isNullOrEmptyOrUndefined(projectName, funcName, "projectName");
Guard.isNullOrEmptyOrUndefined(version, funcName, "version");
Guard.isNullOrEmptyOrUndefined(discordInviteCode, funcName, "discordInviteCode");
Guard.isNothing(branchName, funcName, "branchName");
Guard.isNothing(relativeFilePath, funcName, "relativeFilePath");
Guard.isNothing(projectName, funcName, "projectName");
Guard.isNothing(version, funcName, "version");
Guard.isNothing(discordInviteCode, funcName, "discordInviteCode");

version = version.startsWith("v") ? version : `v${version}`;

Expand Down
Loading
Loading