Skip to content

Release package

Release package #1

Workflow file for this run

---
name: Release package
on:
workflow_dispatch:
inputs:
comments:
description: Comments
required: false
jobs:
release_changelog:
runs-on: ubuntu-latest
steps:
- name: Print author
run: |
echo "Author: ${{ github.triggering_actor }}"
echo "Comments: ${{ github.event.inputs.comments }}"
- name: Extract branch name
shell: bash
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- uses: actions/checkout@master
with:
ref: ${{ steps.extract_branch.outputs.branch }}
- name: Draft change log
uses: release-drafter/release-drafter@v5
id: release-drafter
with:
commitish: ${{ steps.extract_branch.outputs.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set new release version
env:
RD_RELEASE: ${{ steps.release-drafter.outputs.name }}
run: |
if [ ! -z "$RD_RELEASE" ]; then
echo "NEW_RELEASE=$RD_RELEASE" >> $GITHUB_ENV
else
echo "NEW_RELEASE=0.1.0" >> $GITHUB_ENV
fi
- name: Update version in pyproject.toml
uses: jacobtomlinson/gha-find-replace@master
with:
include: pyproject.toml
find: version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"
replace: version = "${{ env.NEW_RELEASE }}"
- name: Commit updates
env:
LATEST_VERSION: ${{ env.NEW_RELEASE }}
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff-index --quiet HEAD || git commit -m "Bump version to $LATEST_VERSION" -a
- name: Push changes
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.BP_PAT_TOKEN }}
unprotect_reviews: true
- name: Publish change log
uses: release-drafter/release-drafter@v5
with:
commitish: ${{ steps.extract_branch_outputs.branch }}
publish: true
name: ${{ env.NEW_RELEASE }}
tag: v${{ env.NEW_RELEASE }}
env:
GITHUB_TOKEN: ${{ secrets.BP_PAT_TOKEN }}