Skip to content

Flip "Unreleased" to "3.1.0" in docs/CHANGELOG.md #30

Flip "Unreleased" to "3.1.0" in docs/CHANGELOG.md

Flip "Unreleased" to "3.1.0" in docs/CHANGELOG.md #30

Workflow file for this run

name: Create a draft release
on:
# Run when manually triggered
workflow_dispatch:
inputs:
version:
description: 'Release version to create, for example 2.3.0'
required: true
default: "2.3.0"
# Run when a release branch is pushed
push:
branches:
- 'release-*.*.*'
defaults:
run:
shell: bash
jobs:
meta:
name: Parse event data into outputs
runs-on: ubuntu-20.04
outputs:
ver: ${{ steps.get-ver.outputs.ver }}
tag: ${{ steps.get-tag.outputs.tag }}
branch: ${{ steps.get-ref.outputs.branch }}
ref: ${{ steps.get-ref.outputs.ref }}
steps:
- name: Checkout ${{ github.repository }}:${{ github.ref }}
uses: actions/checkout@v2
- name: 'ver: Version number for this release'
id: get-ver
run: |
case "${{ github.event_name }}" in
"workflow_dispatch")
_ver="${{ github.event.inputs.version }}" ;;
"push")
_ver="${GITHUB_REF#refs/heads/release-}" ;;
*)
echo "FAIL: Unexpected workflow trigger."
exit 1
esac
echo "::set-output name=ver::${_ver}"
- name: 'tag: Tag for this release'
id: get-tag
run: |
_tag="v${{ steps.get-ver.outputs.ver }}"
echo "::set-output name=tag::${_tag}"
- name: 'branch, ref: Branch for this release'
id: get-ref
run: |
_branch="release-${{ steps.get-ver.outputs.ver }}"
_ref="refs/heads/${_branch}"
echo "::set-output name=branch::${_branch}"
echo "::set-output name=ref::${_ref}"
create-branch:
name: Create the release branch for ${{ needs.meta.outputs.ver }}
needs: meta
if: ${{ github.ref != needs.meta.outputs.ref }}
runs-on: ubuntu-20.04
steps:
- name: Checkout ${{ github.repository }}:${{ github.ref }}
uses: actions/checkout@v2
- name: Configure Git client
run: |
_user="${{ github.repository_owner }}"
_email="${_user}@users.noreply.github.com"
git config user.name "${_user}"
git config user.email "${_email}"
- name: Create branch ${{ needs.meta.outputs.branch }}
run: |
_ghref="${{ github.ref }}"
_myref="${{ needs.meta.outputs.ref }}"
git update-ref "${_myref}" "${_ghref}"
git push origin "${_myref}"
create-release:
name: Create draft release ${{ needs.meta.outputs.tag }}
needs: [meta, create-branch]
environment: uses-pat
runs-on: ubuntu-20.04
steps:
- name: Checkout ${{ github.repository }}:${{ github.ref }}
uses: actions/checkout@v2
- name: Assemble data payload for releases API call
id: get-data
run: |
_repo="${{ github.repository }}"
_tag="${{ needs.meta.outputs.tag }}"
_branch="${{ needs.meta.outputs.branch }}"
_body="words words words"
_draft="true"
_data="{ \"tag_name\": \"${_tag}\", \
\"target_commitish\": \"${_branch}\", \
\"name\": \"${_repo#*/} ${_tag}\", \
\"body\": \"${_body}\", \
\"draft\": ${_draft} }"
echo "::set-output name=data::${_data}"
- name: Call releases API to create draft release
run: |
_data='${{ steps.get-data.outputs.data }}'
echo "${_data}" | \
GITHUB_TOKEN=${{ secrets.PAT }} \
gh api -X POST /repos/:owner/:repo/releases --input -