Skip to content

Fix: trim whitespaces from the fixdat filename (#548) #23

Fix: trim whitespaces from the fixdat filename (#548)

Fix: trim whitespaces from the fixdat filename (#548) #23

# Requires repo secret: PERSONAL_ACCESS_TOKEN with permissions:
# Contents: read and write
# Pull Requests: read
name: Release Drafter
on:
push:
branches:
- 'main'
workflow_dispatch:
inputs:
ref:
description: 'Git ref or SHA'
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
runs-on: ubuntu-latest
env:
ref: ${{ inputs.ref || github.ref || github.sha }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.ref }}
# auto-changelog needs a full fetch for tag info
fetch-depth: 0
# Check to see if the package.json version has changed
- id: check
uses: EndBug/version-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
# NOTE: `diff-search:true` is preferred so that only the exact commit that bumps the
# version triggers this workflow, but `workflow_dispatch` doesn't carry commit or
# commit ref info that's needed for it.
diff-search: ${{ github.event_name != 'workflow_dispatch' && true || false }}
assume-same-version: ${{ github.event_name != 'workflow_dispatch' && 'old' || '' }}
static-checking: ${{ github.event_name == 'workflow_dispatch' && 'localIsNew' || '' }}
file-url: https://unpkg.com/igir/package.json
- if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- if: steps.check.outputs.changed == 'true'
run: npm ci
# Generate the release's markdown template
- if: steps.check.outputs.changed == 'true'
id: auto-changelog
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "MARKDOWN<<$EOF" >> "$GITHUB_OUTPUT"
./scripts/auto-changelog.sh >> "$GITHUB_OUTPUT"
echo "" >> "$GITHUB_OUTPUT"
echo "" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
# Create/update the draft release
- if: steps.check.outputs.changed == 'true'
id: release-drafter
uses: release-drafter/release-drafter@v5
with:
name: v${{ steps.check.outputs.version }}
tag: v${{ steps.check.outputs.version }}
version: ${{ steps.check.outputs.version }}
commitish: ${{ env.ref }}
# NOTE(cemmer): `template` can't be supplied here, only `header` and `footer`, so have to pick one of those
# and make sure the .github/release-drafter.yml's `template` is empty-ish.
header: ${{ steps.auto-changelog.outputs.MARKDOWN }}
env:
# NOTE(cemmer): PAT here causes the release to be made under your account.
# ${{ secrets.GITHUB_TOKEN }} would cause it to be created from `github-actions`, even when published.
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- if: ${{ steps.release-drafter.outputs.id }}
run: |
echo "# v${{ steps.check.outputs.version }} @ ${{ env.ref }}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "${{ steps.release-drafter.outputs.html_url }}" >> "$GITHUB_STEP_SUMMARY"