Skip to content

Commit

Permalink
ci: Automate releases
Browse files Browse the repository at this point in the history
  • Loading branch information
swick authored and GeorgesStavracas committed Oct 8, 2024
1 parent a64be95 commit 9481527
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 19 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Release new version

on:
workflow_dispatch:
inputs:
version:
description: "Release version (MAJOR.MINOR.PATCH, default: extracted from NEWS)"
preRelease:
description: "Is this a pre-release? (true/false, default: true if release version minor number is odd)"
dryRun:
description: "Dry Run (true/false, default: true)"
default: true

jobs:
build-container:
uses: ./.github/workflows/container.yml
permissions:
packages: write

release:
name: Build and publish a release
runs-on: ubuntu-latest
needs: build-container
permissions:
contents: write

container:
image: ${{ needs.build-container.outputs.image }}
options: ${{ needs.build-container.outputs.image_options }}

steps:
- name: Configure git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Checkout the repository
uses: actions/checkout@v4

- name: Update translation files
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
run: |
meson setup . _build
meson compile -C _build/ xdg-desktop-portal-update-po
git add po/*po
git commit -m "Update po files"
git push
git clean -fxd
- name: Build xdg-desktop-portal
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
run: |
meson setup . _build
meson dist -C _build
- name: Extract release information
env:
releaseVersion: ${{ github.event.inputs.version }}
preRelease: ${{ github.event.inputs.preRelease }}
run: |
# Extract the release version
if [ -z $releaseVersion ]; then
releaseVersion=`perl -0777nE 'print $& if /(?<=Changes in ).*/' NEWS`
fi
echo "releaseVersion=$releaseVersion" | tee -a $GITHUB_ENV
# Extract the changelog
{
echo "releaseChangelog<<EOF"
perl -0777nE 'print $& if /(?<=\n\n).*?(?=\n\n)/sg' NEWS
echo "\nEOF"
} | tee -a $GITHUB_ENV
# Check if version is a pre-release
if [ -z $preRelease ]; then
preRelease=$((`echo $releaseVersion | cut -d '.' -f2` % 2))
fi
{
echo -n "preRelease="
if [ $preRelease = 1 ] || [ $preRelease = "true" ]; then
echo "true";
else
echo "false";
fi
} | tee -a $GITHUB_ENV
- name: Tag release
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
run: |
git tag $releaseVersion
git push --tags
- name: Create release
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
uses: ncipollo/[email protected]
with:
tag: ${{ env.releaseVersion }}
body: ${{ env.releaseChangelog }}
prerelease: ${{ env.preRelease }}
artifacts: _build/meson-dist/*
26 changes: 7 additions & 19 deletions RELEASE_HOWTO.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
# Steps for doing a xdg-desktop-portal release

- git clean -fxd
- meson setup . _build && meson compile -C _build/ xdg-desktop-portal-update-po
- git add po/*po && git commit -m "Update po files"
- git clean -fxd
- add content to NEWS
- git commit -m <version>
- git push origin main
- meson setup . _build -Ddocbook-docs=enabled
- meson dist -C _build
- git tag <version>
- git push origin refs/tags/<version>
- upload tarball to github as release
- edit release, copy NEWS section in
- update portal api docs in the gh-pages branch
- bump version in meson.build
- git commit -m "Post-release version bump"
- git push origin main
- Update SECURITY.md if this is a new stable release
- Update .github/ISSUE_TEMPLATE/bug-report.yml if this is a new stable release
- Make sure the version in `meson.build` is correct
- Add your changelog to the `NEWS` file
- Run the "Release new version" GitHub Action
- The options are taken from the last `NEWS` entry by default, you may override them if needed
- Bump version in `meson.build`
- Update `SECURITY.md` if this is a new stable release
- Update `.github/ISSUE_TEMPLATE/bug-report.yml` if this is a new stable release

0 comments on commit 9481527

Please sign in to comment.