Skip to content

Commit

Permalink
Add release automation
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Forró <[email protected]>
  • Loading branch information
nforro committed Aug 12, 2024
1 parent 931eff3 commit df42e96
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/do-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Create a GitHub release once a release PR is merged

on:
workflow_dispatch:
pull_request:
types:
- closed

jobs:
if_merged:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') && github.repository_owner == 'packit'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create GitHub release
run: |
VERSION=$(grep -oP '^# \K[0-9.]+([.\-_]?[a-zA-Z0-9.\-_]+)?' CHANGELOG.md | head -n 1)
# Take the lines between the first two headers from CHANGELOG.md,
# and use it as a description for the new release.
CHANGELOG=$(awk 'BEGIN { first = 0 } /^# / { if (first == 0) { first = 1 } else { exit } } /^[^#]/ { print $0 }' CHANGELOG.md)
# Use the changelog re-calculated to create a new release
gh release create ${VERSION} --draft --title ${VERSION} -n "${CHANGELOG}"
env:
GH_TOKEN: ${{ secrets.RELEASEBOT_GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Prepare a new release
on:
workflow_dispatch:
inputs:
version:
required: true
description: Version number for the new release

jobs:
prepare-release:
# To not run in forks
if: github.repository_owner == 'packit'
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare release content
uses: packit/prepare-release@v3
with:
version: ${{ inputs.version }}
specfiles:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
labels: release
commit-message: Release ${{ inputs.version }}
title: Release ${{ inputs.version }}
body: Update the changelog for release ${{ inputs.version }}.
delete-branch: true
Empty file added CHANGELOG.md
Empty file.

0 comments on commit df42e96

Please sign in to comment.