Skip to content

Release (Main) (release type: patch, dry-run: true, verbose: true) #35

Release (Main) (release type: patch, dry-run: true, verbose: true)

Release (Main) (release type: patch, dry-run: true, verbose: true) #35

Workflow file for this run

name: "Release (Main)"
on:
workflow_dispatch:
inputs:
release_type:
description: "Release type."
required: true
default: "patch"
type: choice
options:
- major
- minor
- patch
verbose:
description: "If to output a summary."
required: false
type: boolean
default: true
dryRun:
description: "If to perform a dryRun without push at the end."
required: false
type: boolean
default: true
workflow_call:
inputs:
release_type:
description: "Release type."
required: true
default: "patch"
type: string
verbose:
description: "If to output a summary."
required: false
type: boolean
default: false
dryRun:
description: "If to perform a dryRun without push at the end."
required: false
type: boolean
default: false
outputs:
releaseVersion:
description: "Released version"
value: ${{ jobs.main.outputs.releaseVersion }}
snapshotVersion:
description: "Next Snapshot Version"
value: ${{ jobs.main.outputs.snapshotVersion }}
artifactName:
description: "Artifact Name"
value: ${{ jobs.main.outputs.artifactName }}
run-name: |
${{ github.workflow }} (release type: ${{ inputs.release_type }}, dry-run: ${{ inputs.dryRun }}, verbose: ${{ inputs.verbose }})
env:
# https://github.com/actions/runner-images/issues/70
NODE_OPTIONS: "--max_old_space_size=4096"
RELEASE_TYPE: ${{ inputs.release_type }}
USER_NAME: ${{ github.actor }}
USER_MAIL: "${{ github.actor }}@users.noreply.github.com"
permissions:
# Requires write permissions, as inc-snapshot-version and release-version
# require it.
contents: write
jobs:
echo-inputs:
name: "Echo Inputs"
runs-on: ubuntu-latest
steps:
- id: echo
name: "Echo Inputs"
run: |
echo "dryRun=${{ inputs.dryRun }}"
echo "release_type=${{ inputs.release_type }}"
echo "verbose=${{ inputs.verbose }}"
about:
name: "About"
uses: "./.github/workflows/about.yml"
main:
name: "Main"
runs-on: ubuntu-latest
timeout-minutes: 10
needs:
- about
env:
nodeVersion: ${{ needs.about.outputs.nodeVersion }}
pnpmVersion: ${{ needs.about.outputs.pnpmVersion }}
outputs:
releaseVersion: ${{ steps.parse-release-version.outputs.result }}
snapshotVersion: ${{ steps.parse-snapshot-version.outputs.result }}
artifactName: ${{ steps.parse-artifact-name.outputs.result }}
steps:
- id: checkout
name: "Checkout"
uses: actions/checkout@v4
- id: installPnpm
name: "Install: Use PNPM ${{ env.pnpmVersion }}"
uses: pnpm/action-setup@v4
with:
version: ${{ env.pnpmVersion }}
run_install: false
- id: installNodeJs
name: "Install: Use Node.js ${{ env.nodeVersion }}"
uses: actions/setup-node@v4
with:
node-version: ${{ env.nodeVersion }}
cache: "pnpm"
- id: install
name: "Install"
run: |
pnpm install --frozen-lockfile
- id: config
name: "Git Config"
run: |
git config --global user.name "${{ env.USER_NAME }}"
git config --global user.email "${{ env.USER_MAIL }}"
echo "Done configuring Git: user.name and user.email."
- id: release
name: "Release"
if: ${{ ! inputs.dryRun }}
run: |
result="$(./sh/release.sh --type "${{ env.RELEASE_TYPE }}" --push)"
echo "RELEASE_INFORMATION=${result}" >> $GITHUB_ENV
- id: release-dry-run
name: "Release (Dry Run)"
if: ${{ inputs.dryRun }}
run: |
result="$(./sh/release.sh --type "${{ env.RELEASE_TYPE }}")"
echo "RELEASE_INFORMATION=${result}" >> $GITHUB_ENV
- id: parse-release-version
name: "Parse Release Version"
run: |
result="$(jq --raw-output '.releaseVersion' <<< '${{ env.RELEASE_INFORMATION }}')"
echo "result=${result}" >> $GITHUB_OUTPUT
- id: parse-snapshot-version
name: "Parse Snapshot Version"
run: |
result="$(jq --raw-output '.snapshotVersion' <<< '${{ env.RELEASE_INFORMATION }}')"
echo "result=${result}" >> $GITHUB_OUTPUT
- id: parse-artifact-name
name: "Parse Artifact Name"
run: |
result="$(jq --raw-output '.artifactName' <<< '${{ env.RELEASE_INFORMATION }}')"
echo "result=${result}" >> $GITHUB_OUTPUT
- id: gh-release
if: ${{ ! inputs.dryRun }}
name: "Create Release"
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fail_on_unmatched_files: true
files: |
${{ steps.parse-artifact-name.outputs.result }}
tag_name: ${{ steps.parse-release-version.outputs.result }}
- id: gh-release-dry-run
if: ${{ inputs.dryRun }}
name: "Create Release (Dry Run)"
run: |
echo "Would create a release ${{ steps.parse-release-version.outputs.result }} with ${{ steps.parse-artifact-name.outputs.result }}."
ls -axl ${{ steps.parse-artifact-name.outputs.result }}
verbose:
name: "Verbose"
runs-on: ubuntu-latest
needs:
- main
if: ${{ inputs.verbose }}
steps:
- id: output
name: "Output"
run: |
echo "# ${{ github.workflow }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Parameters" >> $GITHUB_STEP_SUMMARY
echo "* Released Type: ${{ inputs.release_type }}" >> $GITHUB_STEP_SUMMARY
echo "* Verbose: ${{ inputs.verbose }}" >> $GITHUB_STEP_SUMMARY
echo "* Dry-Run: ${{ inputs.dryRun }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Result" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "* Released Version: ${{ needs.main.outputs.releaseVersion }}" >> $GITHUB_STEP_SUMMARY
echo "* Snapshot Version: ${{ needs.main.outputs.snapshotVersion }}" >> $GITHUB_STEP_SUMMARY
echo "* Artifact: ${{ needs.main.outputs.artifactName }}" >> $GITHUB_STEP_SUMMARY