Release #11
Workflow file for this run
This file contains 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 | |
permissions: | |
contents: write | |
on: | |
workflow_dispatch: | |
inputs: | |
dryRun: | |
description: 'Dry Run' | |
required: true | |
type: boolean | |
default: true | |
releaseVersion: | |
description: 'Custom Version (major.minor.patch; leave empty for automatic determination)' | |
required: true | |
type: choice | |
default: 'auto' | |
options: | |
- 'auto' | |
- 'major' | |
- 'minor' | |
- 'patch' | |
jobs: | |
analyse-changed-packages: | |
runs-on: ubuntu-latest | |
outputs: | |
changed: ${{ steps.changed-packages.outputs.CHANGED }} | |
changedPackages: ${{ steps.changed-packages.outputs.CHANGED_PACKAGES }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- run: | | |
SINCE=$(git rev-list --tags --max-count=1) | |
echo SINCE=$SINCE >> $GITHUB_OUTPUT | |
echo SINCE=$SINCE | |
id: since | |
- run: | | |
pnpm list -r --json --filter "...[$SINCE]" | jq '[.[] | select(.private == false) | {name, path}]' > ./tmp.json | |
CHANGED_PACKAGES=$(jq '[.[] | .name]' ./tmp.json) | |
echo CHANGED_PACKAGES=$CHANGED_PACKAGES >> $GITHUB_OUTPUT | |
echo CHANGED_PACKAGES=$CHANGED_PACKAGES | |
id: changed-packages | |
env: | |
SINCE: ${{ steps.since.outputs.SINCE }} | |
release: | |
needs: [analyse-changed-packages] | |
runs-on: ubuntu-latest | |
if: ${{ needs.analyse-changed-packages.outputs.changedPackages != '[]'}} | |
strategy: | |
fail-fast: false | |
max-parallel: 1 | |
matrix: | |
package: ${{fromJson(needs.analyse-changed-packages.outputs.changedPackages)}} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# token: ${{ secrets.PAT_ME_REPO }} # use PAT to being able to push to protected branch later on | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- run: echo "package=${{ matrix.package }}" | |
- name: get directory for package | |
id: get-directory | |
run: | | |
directory=$(pnpm ls -r --json --filter $MATRIX_PACKAGE | jq -r '.[0] | .path') | |
directory="${directory##*/democracy-development/}" | |
# Ausgabe | |
echo "directory=$directory" >> $GITHUB_OUTPUT | |
echo "directory=$directory" | |
env: | |
MATRIX_PACKAGE: ${{ matrix.package }} | |
- name: Fetch tags | |
run: git fetch --tags | |
- name: Configure CI Git User | |
run: | | |
git config user.name "Manuel Ruck" | |
git config user.email "[email protected]" | |
git config push.followTags true | |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
- name: Get changelog | |
id: get_changelog | |
run: | | |
changelog='' | |
if ( ${{ inputs.releaseVersion == 'auto' }} ); then | |
changelog=`pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --dry-run | sed -n '/^---$/,/^---$/p' | grep -v '^---$'` | |
else | |
changelog=`pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --release-as '${{ inputs.releaseVersion }}' --dry-run | sed -n '/^---$/,/^---$/p' | grep -v '^---$'` | |
fi | |
changelog="${changelog//'%'/'%25'}" | |
changelog="${changelog//$'\n'/'%0A'}" | |
changelog="${changelog//$'\r'/'%0D'}" | |
echo "$changelog" | |
echo "changelog=$changelog" >> $GITHUB_OUTPUT | |
echo "${{ matrix.package }} v$changelog | |
" >> $GITHUB_STEP_SUMMARY | |
working-directory: ${{ steps.get-directory.outputs.directory }} | |
env: | |
MATRIX_PACKAGE: ${{ matrix.package }} | |
- name: Determine next version number | |
if: inputs.releaseVersion == 'auto' | |
run: | | |
nextVersion=`pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --dry-run | sed -n '/^---$/,/^---$/p' | grep -P -o '(\d+\.)(\d+\.)(\d)' | head -n 1` | |
echo "$nextVersion" | |
echo "NEXT_VERSION=$nextVersion" >> $GITHUB_ENV | |
working-directory: ${{ steps.get-directory.outputs.directory }} | |
env: | |
MATRIX_PACKAGE: ${{ matrix.package }} | |
- name: Manually next version number | |
if: inputs.releaseVersion != 'auto' | |
run: | | |
echo "NEXT_VERSION=${{ inputs.releaseVersion }}" >> $GITHUB_ENV | |
echo "$NEXT_VERSION" | |
- name: bump version - DRY RUN | |
if: inputs.dryRun == true | |
run: | | |
if ( ${{ inputs.releaseVersion == 'auto' }} ); then | |
pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --dry-run | |
else | |
pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --release-as '${{ inputs.releaseVersion }}' --dry-run | |
fi | |
working-directory: ${{ steps.get-directory.outputs.directory }} | |
env: | |
MATRIX_PACKAGE: ${{ matrix.package }} | |
- name: bump version - AUTOMATIC | |
if: inputs.dryRun == false && inputs.releaseVersion == 'auto' | |
run: pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v | |
working-directory: ${{ steps.get-directory.outputs.directory }} | |
env: | |
MATRIX_PACKAGE: ${{ matrix.package }} | |
- name: bump version - MANUAL VERSION NO. | |
if: inputs.dryRun == false && inputs.releaseVersion != 'auto' | |
run: pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --release-as '${{ inputs.releaseVersion }}' | |
working-directory: ${{ steps.get-directory.outputs.directory }} | |
env: | |
MATRIX_PACKAGE: ${{ matrix.package }} | |
- name: Publish tag # only possible on default branch | |
if: inputs.dryRun == false | |
run: | | |
if ( ${{ contains(github.ref, github.event.repository.default_branch) }} ); then | |
git push --follow-tags origin ${{ github.event.repository.default_branch }} | |
else | |
exit 1 | |
fi | |
- name: Publish GitHub release | |
uses: ncipollo/release-action@v1 | |
if: inputs.dryRun == false | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} # # use PAT to being able to push to protected branch later on | |
with: | |
tag: $NEXT_VERSION | |
name: $NEXT_VERSION | |
prerelease: true | |
body: | | |
${{ steps.get_changelog.outputs.changelog }} |