Skip to content

GitHub release

GitHub release #74

Workflow file for this run

# This workflow will create the release artifact and a release on GitHub
name: GitHub release
on:
# allows job to be run manually from actions tab
workflow_dispatch:
inputs:
tag:
description: 'Version'
jobs:
build_artefact:
runs-on: ubuntu-latest
steps:
# checks out main into $GITHUB_WORKSPACE
- name: checkout
uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.tag }}'
path: 'TravelWindowII'
# create a zip as a release archive
- name: create release archive
uses: thedoctor0/zip-release@master
with:
filename: 'TravelWindowII-${{ github.event.inputs.tag }}.zip'
exclusions: '*.git* *.github* *.vscode* *.gitignore* /*doc/* /*screenshots/*'
# parse changelog to set release description
- name: extract latest changelog entry
id: changelog
run: |
# Use ${{ github.workspace }} to get the full path to CHANGELOG.md
CHANGELOG_PATH="${{ github.workspace }}/CHANGELOG.md"
# Find the line number of the latest version header
LATEST_VERSION_LINE=$(grep -n "^## v" "$CHANGELOG_PATH" | head -n1 | cut -d: -f1)
# Find the line number of the next version header or EOF
NEXT_VERSION_LINE=$(tail -n +$((LATEST_VERSION_LINE + 1)) "$CHANGELOG_PATH" | grep -n "^## v" | head -n1 | cut -d: -f1)
if [ -z "$NEXT_VERSION_LINE" ]; then
NEXT_VERSION_LINE=$(wc -l < "$CHANGELOG_PATH")
else
NEXT_VERSION_LINE=$((LATEST_VERSION_LINE + NEXT_VERSION_LINE - 1))
fi
# Extract the content between these line numbers
CHANGELOG_CONTENT=$(sed -n "${LATEST_VERSION_LINE},${NEXT_VERSION_LINE}p" "$CHANGELOG_PATH")
# Escape newlines and quote special characters for GitHub Actions
CHANGELOG_CONTENT="${CHANGELOG_CONTENT//'%'/'%25'}"
CHANGELOG_CONTENT="${CHANGELOG_CONTENT//$'\n'/'%0A'}"
CHANGELOG_CONTENT="${CHANGELOG_CONTENT//$'\r'/'%0D'}"
# Set output for use in subsequent steps
echo "::set-output name=content::$CHANGELOG_CONTENT"
# create the GitHub release
- name: create github release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: false
name: ${{ github.event.inputs.tag }}
tag_name: ${{ github.event.inputs.tag }}
body: ${{ steps.changelog.outputs.content }}
files: 'TravelWindowII-${{ github.event.inputs.tag }}.zip'