From 948152744993de85cc8b585f22186c038d6e96e3 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 8 Oct 2024 20:41:26 +0200 Subject: [PATCH] ci: Automate releases --- .github/workflows/release.yml | 101 ++++++++++++++++++++++++++++++++++ RELEASE_HOWTO.md | 26 +++------ 2 files changed, 108 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..d8f97ba16 --- /dev/null +++ b/.github/workflows/release.yml @@ -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< - - git push origin main - - meson setup . _build -Ddocbook-docs=enabled - - meson dist -C _build - - git tag - - git push origin refs/tags/ - - 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