🚀Production Release #89
This file contains hidden or 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
| name: 🚀Release | |
| run-name: 🚀${{ inputs.release-type }} Release ${{ inputs.dry-run == true && '(Dry Run)' || '' }} | |
| defaults: | |
| run: | |
| shell: pwsh | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release-type: | |
| required: true | |
| description: The type of release to validate. Either 'Preview' or 'Production'. | |
| type: choice | |
| options: [Production, Preview] | |
| dry-run: | |
| required: false | |
| description: Dry Run - Check to run the workflow without creating a release. | |
| default: false | |
| type: boolean | |
| env: | |
| OWNER_NAME: "${{ vars.ORGANIZATION_NAME }}" | |
| REPO_NAME: "${{ vars.PROJECT_NAME }}" | |
| jobs: | |
| get_and_validate_version: | |
| name: Get And Validate Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get-version.outputs.version }} | |
| steps: | |
| - name: Get Version | |
| id: get-version | |
| uses: KinsonDigital/Infrastructure/actions/get-version@v16.0.0 | |
| with: | |
| version-file-path: "${{ github.workspace }}/deno.json" | |
| deno-version: "${{ vars.DENO_VERSION }}" | |
| json-prop-path: "version" | |
| - name: Validate Version | |
| id: validate-version | |
| uses: KinsonDigital/Infrastructure/actions/validate-version@v16.0.0 | |
| with: | |
| version: "${{ steps.get-version.outputs.version}}" | |
| release-type: "${{ inputs.release-type }}" | |
| deno-version: "${{ vars.DENO_VERSION }}" | |
| run_prerelease_validation: | |
| name: Run Pre-Release Validation | |
| needs: [get_and_validate_version] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check Branch | |
| id: check-branch | |
| continue-on-error: true | |
| run: | | |
| if ("${{ github.ref_name }}" -ne "main") { | |
| exit 1; | |
| } | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| - name: Set Up Deno (${{ vars.DENO_VERSION }}) | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: ${{ vars.DENO_VERSION }} | |
| cache: true | |
| - name: Milestone Exists | |
| id: milestone-exists | |
| uses: KinsonDigital/Infrastructure/actions/milestone-exists@v16.0.0 | |
| with: | |
| owner-name: "${{ vars.ORGANIZATION_NAME }}" | |
| repo-name: "${{ vars.PROJECT_NAME }}" | |
| milestone-name: "${{ needs.get_and_validate_version.outputs.version }}" | |
| github-token: "${{ secrets.CICD_TOKEN }}" | |
| deno-version: "${{ vars.DENO_VERSION }}" | |
| - name: Validate Milestone Items | |
| id: milestone-items-check | |
| uses: KinsonDigital/Infrastructure/actions/milestone-items-closed@v16.0.0 | |
| with: | |
| owner-name: "${{ vars.ORGANIZATION_NAME }}" | |
| repo-name: "${{ vars.PROJECT_NAME }}" | |
| milestone-name: "${{ needs.get_and_validate_version.outputs.version }}" | |
| github-token: "${{ secrets.CICD_TOKEN }}" | |
| deno-version: "${{ vars.DENO_VERSION }}" | |
| fail-if-all-items-not-closed: true | |
| continue-on-error: false | |
| - name: Lowercase Release Type | |
| id: release-type | |
| run: | | |
| $releaseType = "${{ inputs.release-type }}".ToLower(); | |
| "release-type=$releaseType" > "$env:GITHUB_OUTPUT"; | |
| - name: Release Notes Exist | |
| id: release-notes-check | |
| uses: KinsonDigital/Infrastructure/actions/release-notes-exist@v16.0.0 | |
| with: | |
| release-notes-file-path: "${{ github.workspace }}/release-notes/${{ steps.release-type.outputs.release-type }}-releases/Release-Notes-${{ needs.get_and_validate_version.outputs.version }}.md" | |
| deno-version: "${{ vars.DENO_VERSION }}" | |
| fail-if-does-not-exist: true | |
| continue-on-error: true | |
| - name: GitHub Release Exists | |
| id: github-release-check | |
| uses: KinsonDigital/Infrastructure/actions/github-release-exists@v16.0.0 | |
| with: | |
| owner-name: "${{ vars.ORGANIZATION_NAME }}" | |
| repo-name: "${{ vars.PROJECT_NAME }}" | |
| tag-name: "${{ needs.get_and_validate_version.outputs.version }}" | |
| deno-version: "${{ vars.DENO_VERSION }}" | |
| github-token: "${{ secrets.CICD_TOKEN }}" | |
| continue-on-error: true | |
| - name: Should Fail Job | |
| run: | | |
| $validBranch = "${{ steps.check-branch.outcome == 'failure' }}"; | |
| $milestoneExists = "${{ steps.milestone-exists.outputs.milestone-exists }}"; | |
| $milestoneItemsCheckFailed = "${{ steps.milestone-items-check.outcome == 'failure' }}"; | |
| $releaseNotesCheckFailed = "${{ steps.release-notes-check.outcome == 'failure' }}"; | |
| $githubReleaseCheckFailed = "${{ steps.github-release-check.outcome == 'failure' }}"; | |
| if ($validBranch -eq "true") { | |
| Write-Host "::error::The branch '${{ github.ref_name }}' is invalid. Must run on the 'main' branch."; | |
| } | |
| if ($milestoneExists -eq "false") { | |
| Write-Host "::error::The milestone '${{ needs.get_and_validate_version.outputs.version }}' does not exist."; | |
| } | |
| if ($milestoneItemsCheckFailed -eq "true") { | |
| Write-Host "::error::The milestone '${{ needs.get_and_validate_version.outputs.version }}' has one or more issues that are not closed or prs that are in draft."; | |
| } | |
| if ($releaseNotesCheckFailed -eq "true") { | |
| Write-Host "::error::The release notes do not exist."; | |
| } | |
| if ($githubReleaseCheckFailed -eq "true") { | |
| Write-Host "::error::The GitHub release already exists."; | |
| } | |
| if ($validBranch -eq "true" ` | |
| -or $milestoneExists -eq "false" ` | |
| -or $milestoneItemsCheckFailed -eq "true" ` | |
| -or $releaseNotesCheckFailed -eq "true" ` | |
| -or $githubReleaseCheckFailed -eq "true") { | |
| exit 1; | |
| } | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: [get_and_validate_version, run_prerelease_validation] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| - name: Set Up Deno (${{ vars.DENO_VERSION }}) | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: ${{ vars.DENO_VERSION }} | |
| cache: true | |
| - name: Build | |
| run: deno check ./**/*.ts; | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| needs: [get_and_validate_version, run_prerelease_validation] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| - name: Set Up Deno (${{ vars.DENO_VERSION }}) | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: ${{ vars.DENO_VERSION }} | |
| cache: true | |
| - name: Lint | |
| run: deno lint "./**/*.ts"; | |
| perform_release: | |
| name: Perform ${{ inputs.release-type }} Release | |
| runs-on: ubuntu-latest | |
| needs: [get_and_validate_version, run_prerelease_validation, build, lint] | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.CICD_TOKEN }} | |
| - name: Set Up Deno (${{ vars.DENO_VERSION }}) | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: ${{ vars.DENO_VERSION }} | |
| cache: true | |
| - name: Lowercase Release Type | |
| id: release-type | |
| run: | | |
| $releaseType = "${{ inputs.release-type }}".ToLower(); | |
| "release-type=$releaseType" > "$env:GITHUB_OUTPUT"; | |
| - name: Update Reusable Workflow Versions ${{ inputs.dry-run == true && '(Dry Run)' || '' }} | |
| if: inputs.dry-run == false | |
| env: | |
| BASE_DIR_PATH: "${{ github.workspace }}/.github/workflows" | |
| NEW_VERSION: "${{ needs.get_and_validate_version.outputs.version }}" | |
| GITHUB_TOKEN: "${{ secrets.CICD_TOKEN }}" | |
| run: | | |
| if ("${{ inputs.dry-run == true }}" -eq "true") { | |
| Write-Host "::notice::Updating 'INFRASTRUCTURE_VERSION' repository variable ..."; | |
| exit 0; | |
| } | |
| deno run -ERWN "${{ github.workspace }}/.github/internal-cicd/scripts/update-workflow-versions.ts"; | |
| $releaseType = "${{ inputs.release-type }}"; | |
| git config --global user.email "${{ vars.GIT_CONFIG_EMAIL }}"; | |
| git config --global user.name "CICD Release Script - (On behalf of Calvin Wilkinson)"; | |
| git add -A; | |
| git commit -m "🚀$releaseType (${{ needs.get_and_validate_version.outputs.version }}) - Update reusable workflow versions"; | |
| git push; | |
| - name: Create GitHub Release ${{ inputs.dry-run == true && '(Dry Run)' || '' }} | |
| if: inputs.dry-run == false | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| name: "🚀${{ inputs.release-type }} - ${{ needs.get_and_validate_version.outputs.version }}" | |
| tag: ${{ needs.get_and_validate_version.outputs.version }} | |
| owner: ${{ env.OWNER_NAME }} | |
| repo: ${{ env.REPO_NAME }} | |
| bodyFile: "${{ github.workspace }}/release-notes/${{ steps.release-type.outputs.release-type }}-releases/Release-Notes-${{ needs.get_and_validate_version.outputs.version }}.md" | |
| artifacts: "${{ github.workspace }}/release-notes/${{ steps.release-type.outputs.release-type }}-releases/Release-Notes-${{ needs.get_and_validate_version.outputs.version }}.md" | |
| prerelease: ${{ inputs.release-type }} == 'Preview' | |
| - name: Close Milestone ${{ inputs.dry-run == true && '(Dry Run)' || '' }} | |
| if: inputs.dry-run == false | |
| uses: KinsonDigital/Infrastructure/actions/close-milestone@v16.0.0 | |
| with: | |
| repo-owner: "${{ vars.ORGANIZATION_NAME }}" | |
| repo-name: "${{ vars.PROJECT_NAME }}" | |
| github-token: "${{ secrets.CICD_TOKEN }}" | |
| milestone-title: "${{ needs.get_and_validate_version.outputs.version }}" | |
| deno-version: "${{ vars.DENO_VERSION }}" | |
| - name: Update CICD Script Version Repo Var ${{ inputs.dry-run == true && '(Dry Run)' || '' }} | |
| env: | |
| INFRASTRUCTURE_VERSION_REPO_VAR_NAME: "INFRASTRUCTURE_VERSION" | |
| VERSION: "${{ needs.get_and_validate_version.outputs.version }}" | |
| GITHUB_TOKEN: "${{ secrets.CICD_TOKEN }}" | |
| run: | | |
| if ("${{ inputs.dry-run == true }}" -eq "true") { | |
| Write-Host "::notice::Updating 'INFRASTRUCTURE_VERSION' repository variable ..."; | |
| exit 0; | |
| } | |
| deno run -EN "${{ github.workspace }}/.github/internal-cicd/scripts/update-cicd-script-version.ts"; |