From d41e232d97cec070fabd1941af1b03d1f8b9bd09 Mon Sep 17 00:00:00 2001 From: Staaaszek Date: Thu, 26 Nov 2026 10:44:03 +0100 Subject: [PATCH 1/6] Publish to the AUR on every push to the stable branch The PKGBUILD in aur/ is now the one that gets published: the source points at the GitHub tag tarball again, the build uses the extracted Email-Client- directory, and gpm is listed as a runtime dependency. Bump the version to 2.1.0, since the AUR already has 2.0.0. --- .github/workflows/aur-release.yml | 160 ++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 5 +- CMakeLists.txt | 2 +- aur/PKGBUILD | 44 +++----- 4 files changed, 180 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/aur-release.yml diff --git a/.github/workflows/aur-release.yml b/.github/workflows/aur-release.yml new file mode 100644 index 0000000..5850373 --- /dev/null +++ b/.github/workflows/aur-release.yml @@ -0,0 +1,160 @@ +name: AUR release + +# Every push to `stable` releases the version from project(VERSION) in +# CMakeLists.txt to the AUR: it tags the commit as , fills in +# aur/PKGBUILD and pushes it with a fresh .SRCINFO to the AUR repository. +# A push whose - is already on the AUR publishes nothing. +# +# Needs the AUR_SSH_PRIVATE_KEY secret: the private SSH key whose public key is +# set on the AUR account that maintains the package. +on: + push: + branches: [stable] + +# Never two releases at once; a newer push waits instead of cancelling +concurrency: + group: aur-release + cancel-in-progress: false + +jobs: + ci: + uses: ./.github/workflows/ci.yml + + release: + needs: ci + runs-on: ubuntu-24.04 + container: archlinux:latest + permissions: + contents: write # pushing the version tag + env: + AUR_REPO: ssh://aur@aur.archlinux.org/email-client.git + steps: + - name: Install dependencies + run: pacman -Syu --noconfirm --needed base-devel git openssh sudo + + - uses: actions/checkout@v5 + with: + fetch-depth: 0 # tags, to see whether this version is already tagged + + - name: Set up SSH for the AUR + env: + AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + run: | + [ -n "$AUR_SSH_PRIVATE_KEY" ] || { echo "::error::The AUR_SSH_PRIVATE_KEY secret is not set"; exit 1; } + # Explicit paths: in a container job HOME is not the home directory ssh uses + install -dm700 /etc/aur-ssh + printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > /etc/aur-ssh/key + chmod 600 /etc/aur-ssh/key + # Pinned host key (SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4, as on the Arch wiki) + echo 'aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN' > /etc/aur-ssh/known_hosts + echo "GIT_SSH_COMMAND=ssh -F /dev/null -i /etc/aur-ssh/key -o IdentitiesOnly=yes -o UserKnownHostsFile=/etc/aur-ssh/known_hosts -o StrictHostKeyChecking=yes" >> "$GITHUB_ENV" + git config --global --add safe.directory '*' + + - name: Decide what to release + id: version + run: | + git clone "$AUR_REPO" aur-repo + + pkgver=$(sed -n '/^project(/,/)/s/^ *VERSION *\([0-9.]*\).*/\1/p' CMakeLists.txt) + pkgrel=$(sed -n 's/^pkgrel=//p' aur/PKGBUILD) + [ -n "$pkgver" ] && [ -n "$pkgrel" ] || { echo "::error::Cannot read the version"; exit 1; } + new="$pkgver-$pkgrel" + + old="" + if [ -f aur-repo/.SRCINFO ]; then + old="$(sed -n 's/^\tpkgver = //p' aur-repo/.SRCINFO)-$(sed -n 's/^\tpkgrel = //p' aur-repo/.SRCINFO)" + fi + echo "AUR has ${old:-nothing}, this commit is $new" + + publish=true + if [ -n "$old" ]; then + case $(vercmp "$new" "$old") in + 0) publish=false + echo "::notice::$new is already on the AUR; bump project(VERSION) in CMakeLists.txt (or pkgrel in aur/PKGBUILD) to release" ;; + -1) echo "::error::$new is older than $old on the AUR"; exit 1 ;; + esac + fi + + # An existing tag is the released source of that version: a pkgrel bump + # republishes it unchanged, it does not move the tag to this commit + if tag=$(git rev-parse -q --verify "refs/tags/$pkgver^{commit}"); then + tag_exists=true + [ "$tag" = "$GITHUB_SHA" ] || [ "$publish" = false ] || \ + echo "::warning::Tag $pkgver already exists on $tag, so it is packaged instead of this commit; bump project(VERSION) to release the new code" + else + tag_exists=false + fi + + { + echo "pkgver=$pkgver" + echo "pkgrel=$pkgrel" + echo "publish=$publish" + echo "tag_exists=$tag_exists" + } >> "$GITHUB_OUTPUT" + + # Build the package from a local copy of the source before tagging, so a + # broken package leaves neither a tag nor an AUR update behind + - name: Test build of the package + if: steps.version.outputs.publish == 'true' + env: + PKGVER: ${{ steps.version.outputs.pkgver }} + TAG_EXISTS: ${{ steps.version.outputs.tag_exists }} + run: | + useradd -m builder + echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder + + ref=HEAD + [ "$TAG_EXISTS" = true ] && ref="refs/tags/$PKGVER" + install -d -o builder /home/builder/pkg + git archive --prefix="Email-Client-$PKGVER/" -o "/home/builder/pkg/email-client-$PKGVER.tar.gz" "$ref" + sed -e "s/^pkgver=.*/pkgver=$PKGVER/" \ + -e 's|^source=.*|source=("${pkgname}-${pkgver}.tar.gz")|' \ + aur/PKGBUILD > /home/builder/pkg/PKGBUILD + chown -R builder /home/builder/pkg + + # vmime is an AUR dependency, so pacman cannot install it + sudo -u builder bash -euo pipefail -c ' + cd ~ + git clone https://aur.archlinux.org/vmime.git + # A split package: vmime and vmime-libonly conflict, so install only vmime + (cd vmime && makepkg -s --noconfirm && + sudo pacman -U --noconfirm "$(makepkg --packagelist | grep "/vmime-[0-9]")") + cd pkg && makepkg -si --noconfirm + ' + # Every library must come from an installed package, not from the build tree + if ldd /usr/bin/email_client | grep -E 'not found|/home/'; then + echo "::error::The packaged email_client is missing libraries"; exit 1 + fi + + - name: Tag the release + if: steps.version.outputs.publish == 'true' && steps.version.outputs.tag_exists == 'false' + env: + PKGVER: ${{ steps.version.outputs.pkgver }} + run: | + git tag "$PKGVER" "$GITHUB_SHA" + git push origin "refs/tags/$PKGVER" + + - name: Publish to the AUR + if: steps.version.outputs.publish == 'true' + env: + PKGVER: ${{ steps.version.outputs.pkgver }} + PKGREL: ${{ steps.version.outputs.pkgrel }} + run: | + url="https://github.com/Student-Team-Projects/Email-Client/archive/refs/tags/$PKGVER.tar.gz" + sum=$(curl -fsSL --retry 5 --retry-all-errors "$url" | sha256sum | cut -d' ' -f1) + + sed -e "s/^pkgver=.*/pkgver=$PKGVER/" \ + -e "s/^sha256sums=.*/sha256sums=('$sum')/" \ + aur/PKGBUILD > aur-repo/PKGBUILD + # makepkg refuses to run as root + install -d -o builder /home/builder/srcinfo + cp aur-repo/PKGBUILD /home/builder/srcinfo/ + (cd /home/builder/srcinfo && sudo -u builder makepkg --printsrcinfo) > aur-repo/.SRCINFO + + cd aur-repo + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add PKGBUILD .SRCINFO + git commit -m "Update to $PKGVER-$PKGREL" \ + -m "From ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}" + git push origin HEAD:master diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfb04c9..f0470c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,13 @@ name: CI # Every push to any branch, plus pull requests (needed for PRs from forks, -# whose pushes do not run workflows in this repository) +# whose pushes do not run workflows in this repository). Pushes to `stable` are +# tested by aur-release.yml, which calls this workflow before releasing. on: push: + branches-ignore: [stable] pull_request: + workflow_call: # A newer push to the same branch or PR cancels the older, now outdated run; # on main every commit is tested to the end diff --git a/CMakeLists.txt b/CMakeLists.txt index 4956436..3e39042 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22) project(email_client LANGUAGES CXX - VERSION 1.0.0 + VERSION 2.1.0 ) set(CMAKE_CXX_STANDARD 20) diff --git a/aur/PKGBUILD b/aur/PKGBUILD index 12166da..b901013 100644 --- a/aur/PKGBUILD +++ b/aur/PKGBUILD @@ -1,8 +1,14 @@ # Please report maintenance problems to the project GitHub issue tracker # i.e. https://github.com/Student-Team-Projects/email-client/issues +# Published to the AUR by .github/workflows/aur-release.yml on every push to the +# `stable` branch. pkgver and sha256sums are filled in by the workflow (pkgver +# comes from project(VERSION) in CMakeLists.txt), so do not edit them here. +# Bump pkgrel only for a packaging-only fix of an already released version, +# and reset it to 1 together with a version bump. + pkgname=email-client -pkgver=2.0.0 +pkgver=0.0.0 pkgrel=1 pkgdesc="A CLI email client for Arch Linux" arch=('x86_64') @@ -16,6 +22,7 @@ depends=( 'icu' 'gnutls' 'ncurses' + 'gpm' 'libffi' 'sqlite' 'libxml2' @@ -24,46 +31,25 @@ depends=( 'vmime' ) -# Build Dependencies +# Build Dependencies (git: CMake fetches the bundled libraries with it) makedepends=( - 'base-devel' 'cmake' - 'make' - 'gcc' 'git' 'pkgconf' ) -# Sources and Checksums -# WARN: PIN THESE BACK BEFORE PUSHING PKGBUILD TO AUR -# source=("https://github.com/Student-Team-Projects/Email-Client/archive/refs/tags/${pkgver}.tar.gz") -# sha256sums=('TODO!') - -source=("http://127.0.0.1:8000/${pkgver}.tar.gz") +source=("${pkgname}-${pkgver}.tar.gz::https://github.com/Student-Team-Projects/Email-Client/archive/refs/tags/${pkgver}.tar.gz") sha256sums=('SKIP') -prepare() { - cd "$srcdir" || exit 1 - tar xzvf "${pkgver}.tar.gz" -} - build() { - cd "$srcdir" || exit 1 - mkdir -p build - cd build || exit 1 - - cmake -DCMAKE_BUILD_TYPE=Release \ + cmake -S "Email-Client-${pkgver}" -B build \ + -DCMAKE_BUILD_TYPE=Release \ -DEXTERNAL_SQLITE=ON \ -DEXTERNAL_LIBXML2=ON \ - -DEXTERNAL_VMIME=ON .. - make + -DEXTERNAL_VMIME=ON + cmake --build build --parallel "$(nproc)" } package() { - cd "$srcdir/build" || exit 1 - - # Install the email client binary - install -Dm755 "email_client" "$pkgdir/usr/bin/email_client" - - # TODO: Consider adding manpages (e.g via scdoc ;) + install -Dm755 build/email_client "$pkgdir/usr/bin/email_client" } From 1cde353cbb4d09f0e1ccc3c838d19914f4f04b5e Mon Sep 17 00:00:00 2001 From: Staaaszek Date: Thu, 26 Nov 2026 10:49:50 +0100 Subject: [PATCH 2/6] Release to the AUR from main instead of a stable branch --- .github/workflows/aur-release.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- aur/PKGBUILD | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/aur-release.yml b/.github/workflows/aur-release.yml index 5850373..a8a88da 100644 --- a/.github/workflows/aur-release.yml +++ b/.github/workflows/aur-release.yml @@ -1,6 +1,6 @@ name: AUR release -# Every push to `stable` releases the version from project(VERSION) in +# Every push to `main` releases the version from project(VERSION) in # CMakeLists.txt to the AUR: it tags the commit as , fills in # aur/PKGBUILD and pushes it with a fresh .SRCINFO to the AUR repository. # A push whose - is already on the AUR publishes nothing. @@ -9,7 +9,7 @@ name: AUR release # set on the AUR account that maintains the package. on: push: - branches: [stable] + branches: [main] # Never two releases at once; a newer push waits instead of cancelling concurrency: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0470c9..54bac25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,11 @@ name: CI # Every push to any branch, plus pull requests (needed for PRs from forks, -# whose pushes do not run workflows in this repository). Pushes to `stable` are +# whose pushes do not run workflows in this repository). Pushes to `main` are # tested by aur-release.yml, which calls this workflow before releasing. on: push: - branches-ignore: [stable] + branches-ignore: [main] pull_request: workflow_call: diff --git a/aur/PKGBUILD b/aur/PKGBUILD index b901013..6f1b734 100644 --- a/aur/PKGBUILD +++ b/aur/PKGBUILD @@ -2,7 +2,7 @@ # i.e. https://github.com/Student-Team-Projects/email-client/issues # Published to the AUR by .github/workflows/aur-release.yml on every push to the -# `stable` branch. pkgver and sha256sums are filled in by the workflow (pkgver +# `main` branch. pkgver and sha256sums are filled in by the workflow (pkgver # comes from project(VERSION) in CMakeLists.txt), so do not edit them here. # Bump pkgrel only for a packaging-only fix of an already released version, # and reset it to 1 together with a version bump. From 2c2c5efaf8c407ee43107c9f9a7124475de96b09 Mon Sep 17 00:00:00 2001 From: Staaaszek Date: Thu, 26 Nov 2026 10:45:14 +0100 Subject: [PATCH 3/6] Announce PRs merged into main on Discord --- .github/workflows/discord-pr-merged.yml | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/discord-pr-merged.yml diff --git a/.github/workflows/discord-pr-merged.yml b/.github/workflows/discord-pr-merged.yml new file mode 100644 index 0000000..20e9cd3 --- /dev/null +++ b/.github/workflows/discord-pr-merged.yml @@ -0,0 +1,75 @@ +name: Discord PR merged + +# Announces every pull request merged into main on the team's Discord channel. +# pull_request_target so that PRs from forks also have access to the webhook +# secret; it is safe here because the job never checks out or runs PR code. +on: + pull_request_target: + types: [closed] + branches: [main] + +permissions: {} + +jobs: + notify: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Send Discord message + env: + WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} + # Passed through env, never interpolated into the script, because + # the PR title and author are controlled by whoever opened the PR + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_AUTHOR_AVATAR: ${{ github.event.pull_request.user.avatar_url }} + MERGED_BY: ${{ github.event.pull_request.merged_by.login }} + HEAD_BRANCH: ${{ github.event.pull_request.head.label }} + COMMITS: ${{ github.event.pull_request.commits }} + ADDITIONS: ${{ github.event.pull_request.additions }} + DELETIONS: ${{ github.event.pull_request.deletions }} + CHANGED_FILES: ${{ github.event.pull_request.changed_files }} + run: | + if [ -z "$WEBHOOK" ]; then + echo "::warning::DISCORD_WEBHOOK_URL secret is not set, skipping" + exit 0 + fi + + payload=$(jq -n \ + --arg number "$PR_NUMBER" \ + --arg title "$PR_TITLE" \ + --arg url "$PR_URL" \ + --arg author "$PR_AUTHOR" \ + --arg avatar "$PR_AUTHOR_AVATAR" \ + --arg merged_by "$MERGED_BY" \ + --arg branch "$HEAD_BRANCH" \ + --arg commits "$COMMITS" \ + --arg additions "$ADDITIONS" \ + --arg deletions "$DELETIONS" \ + --arg files "$CHANGED_FILES" \ + '{ + username: "Merge Alarm 🚨", + allowed_mentions: { parse: [] }, + content: "🚨🚨🚨 **ALARM! ALARM! NOWY MERGE DO MAIN!** 🚨🚨🚨\nπŸŽ‰πŸŽŠπŸ₯³ TO SIĘ DZIEJE NAPRAWDĘ!!! πŸ₯³πŸŽŠπŸŽ‰", + embeds: [{ + title: ("πŸŽ‰ #" + $number + " " + $title + " πŸŽ‰"), + url: $url, + color: 16766720, + author: { name: $author, icon_url: $avatar }, + description: ("πŸ”₯πŸ”₯πŸ”₯ **" + $author + "** wΕ‚aΕ›nie dowiΓ³zΕ‚(a) kod na `main`!!! πŸ”₯πŸ”₯πŸ”₯\n\nπŸš€ Lecimy w kosmos! πŸš€ Szampan otwarty! 🍾πŸ₯‚\n🎊 KONFETTI WSZĘDZIE 🎊 πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰"), + fields: [ + { name: "🌿 GaΕ‚Δ…ΕΊ", value: ("`" + $branch + "`"), inline: true }, + { name: "βœ… ZmergowaΕ‚(a)", value: $merged_by, inline: true }, + { name: "πŸ“¦ Commity", value: $commits, inline: true }, + { name: "πŸ“ˆ Zmiany", value: ("🟒 +" + $additions + " πŸ”΄ -" + $deletions + " πŸ“„ " + $files + " plikΓ³w"), inline: false } + ], + footer: { text: "🎊 Kolejny krok bliΕΌej stable! 🎊" } + }] + }') + + curl --fail-with-body -sS \ + -H "Content-Type: application/json" \ + -d "$payload" \ + "$WEBHOOK" From 313ece0bcf600375545792781c8671182a40bec7 Mon Sep 17 00:00:00 2001 From: Staaaszek Date: Thu, 26 Nov 2026 10:48:07 +0100 Subject: [PATCH 4/6] Shorten the Discord merge message --- .github/workflows/discord-pr-merged.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/discord-pr-merged.yml b/.github/workflows/discord-pr-merged.yml index 20e9cd3..537b3a2 100644 --- a/.github/workflows/discord-pr-merged.yml +++ b/.github/workflows/discord-pr-merged.yml @@ -27,10 +27,8 @@ jobs: PR_AUTHOR_AVATAR: ${{ github.event.pull_request.user.avatar_url }} MERGED_BY: ${{ github.event.pull_request.merged_by.login }} HEAD_BRANCH: ${{ github.event.pull_request.head.label }} - COMMITS: ${{ github.event.pull_request.commits }} ADDITIONS: ${{ github.event.pull_request.additions }} DELETIONS: ${{ github.event.pull_request.deletions }} - CHANGED_FILES: ${{ github.event.pull_request.changed_files }} run: | if [ -z "$WEBHOOK" ]; then echo "::warning::DISCORD_WEBHOOK_URL secret is not set, skipping" @@ -45,27 +43,23 @@ jobs: --arg avatar "$PR_AUTHOR_AVATAR" \ --arg merged_by "$MERGED_BY" \ --arg branch "$HEAD_BRANCH" \ - --arg commits "$COMMITS" \ --arg additions "$ADDITIONS" \ --arg deletions "$DELETIONS" \ - --arg files "$CHANGED_FILES" \ '{ username: "Merge Alarm 🚨", allowed_mentions: { parse: [] }, - content: "🚨🚨🚨 **ALARM! ALARM! NOWY MERGE DO MAIN!** 🚨🚨🚨\nπŸŽ‰πŸŽŠπŸ₯³ TO SIĘ DZIEJE NAPRAWDĘ!!! πŸ₯³πŸŽŠπŸŽ‰", + content: "πŸš¨πŸŽ‰ **Nowy merge do main!** πŸŽŠπŸš€", embeds: [{ - title: ("πŸŽ‰ #" + $number + " " + $title + " πŸŽ‰"), + title: ("#" + $number + " " + $title), url: $url, color: 16766720, author: { name: $author, icon_url: $avatar }, - description: ("πŸ”₯πŸ”₯πŸ”₯ **" + $author + "** wΕ‚aΕ›nie dowiΓ³zΕ‚(a) kod na `main`!!! πŸ”₯πŸ”₯πŸ”₯\n\nπŸš€ Lecimy w kosmos! πŸš€ Szampan otwarty! 🍾πŸ₯‚\n🎊 KONFETTI WSZĘDZIE 🎊 πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰"), + description: ("πŸ₯³ Brawo, **" + $author + "**! Kod juΕΌ na `main` πŸ”₯"), fields: [ - { name: "🌿 GaΕ‚Δ…ΕΊ", value: ("`" + $branch + "`"), inline: true }, + { name: "🌿 Branch", value: ("`" + $branch + "`"), inline: true }, { name: "βœ… ZmergowaΕ‚(a)", value: $merged_by, inline: true }, - { name: "πŸ“¦ Commity", value: $commits, inline: true }, - { name: "πŸ“ˆ Zmiany", value: ("🟒 +" + $additions + " πŸ”΄ -" + $deletions + " πŸ“„ " + $files + " plikΓ³w"), inline: false } - ], - footer: { text: "🎊 Kolejny krok bliΕΌej stable! 🎊" } + { name: "πŸ“ˆ Zmiany", value: ("+" + $additions + " / -" + $deletions), inline: true } + ] }] }') From 2c709ad91b2eab3060e66e23ab7bfc8c43571e69 Mon Sep 17 00:00:00 2001 From: Staaaszek Date: Thu, 26 Nov 2026 10:54:11 +0100 Subject: [PATCH 5/6] Post the outcome of an AUR release to Discord --- .github/workflows/aur-release.yml | 77 ++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/.github/workflows/aur-release.yml b/.github/workflows/aur-release.yml index a8a88da..3d09be9 100644 --- a/.github/workflows/aur-release.yml +++ b/.github/workflows/aur-release.yml @@ -6,7 +6,8 @@ name: AUR release # A push whose - is already on the AUR publishes nothing. # # Needs the AUR_SSH_PRIVATE_KEY secret: the private SSH key whose public key is -# set on the AUR account that maintains the package. +# set on the AUR account that maintains the package. The outcome of a release +# (or a failure of this workflow) is posted to Discord via DISCORD_WEBHOOK_URL. on: push: branches: [main] @@ -26,6 +27,9 @@ jobs: container: archlinux:latest permissions: contents: write # pushing the version tag + outputs: + publish: ${{ steps.version.outputs.publish }} + version: ${{ steps.version.outputs.pkgver }}-${{ steps.version.outputs.pkgrel }} env: AUR_REPO: ssh://aur@aur.archlinux.org/email-client.git steps: @@ -158,3 +162,74 @@ jobs: git commit -m "Update to $PKGVER-$PKGREL" \ -m "From ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}" git push origin HEAD:master + + # One message per release attempt: success when a new version reached the + # AUR, failure when the CI or the release broke. Nothing when there was + # nothing new to release. + notify: + needs: [ci, release] + if: >- + always() && (needs.release.outputs.publish == 'true' + || contains(fromJSON('["failure", "cancelled"]'), needs.ci.result) + || contains(fromJSON('["failure", "cancelled"]'), needs.release.result)) + runs-on: ubuntu-latest + permissions: {} + steps: + - name: Send Discord message + env: + WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} + CI_RESULT: ${{ needs.ci.result }} + RELEASE_RESULT: ${{ needs.release.result }} + VERSION: ${{ needs.release.outputs.version }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} + SHORT_SHA: ${{ github.sha }} + run: | + if [ -z "$WEBHOOK" ]; then + echo "::warning::DISCORD_WEBHOOK_URL secret is not set, skipping" + exit 0 + fi + + if [ "$CI_RESULT" = success ] && [ "$RELEASE_RESULT" = success ]; then + payload=$(jq -n --arg version "$VERSION" --arg run "$RUN_URL" '{ + username: "Release Alarm πŸ“¦", + allowed_mentions: { parse: [] }, + content: "πŸ“¦πŸŽ‰ **Nowa wersja w AUR!** πŸš€", + embeds: [{ + title: ("email-client " + $version), + url: "https://aur.archlinux.org/packages/email-client", + color: 3066993, + description: "Gotowe do instalacji: `yay -S email-client` πŸ”₯", + fields: [ + { name: "πŸ”§ Workflow", value: ("[logi](" + $run + ")"), inline: true } + ] + }] + }') + else + if [ "$CI_RESULT" != success ]; then + stage="CI" + else + stage="Release" + fi + payload=$(jq -n --arg stage "$stage" --arg run "$RUN_URL" \ + --arg commit "$COMMIT_URL" --arg sha "${SHORT_SHA:0:7}" --arg version "$VERSION" '{ + username: "Release Alarm πŸ“¦", + allowed_mentions: { parse: [] }, + content: (if $stage == "CI" then "❌ **CI na main nie przeszΕ‚o**" else "❌ **Release do AUR nie poszedΕ‚**" end), + embeds: [{ + title: ("PadΕ‚o na etapie: " + $stage), + url: $run, + color: 15158332, + description: "AUR bez zmian. SzczegΓ³Ε‚y w logach workflow πŸ‘†", + fields: ([ + { name: "πŸ“Œ Commit", value: ("[`" + $sha + "`](" + $commit + ")"), inline: true } + ] + (if $version != "-" and $version != "" then + [{ name: "πŸ“¦ Wersja", value: $version, inline: true }] else [] end)) + }] + }') + fi + + curl --fail-with-body -sS \ + -H "Content-Type: application/json" \ + -d "$payload" \ + "$WEBHOOK" From 966e95a44ad69aa6bbe2a5fe549f0f5f48c16693 Mon Sep 17 00:00:00 2001 From: Staaaszek Date: Thu, 26 Nov 2026 10:55:56 +0100 Subject: [PATCH 6/6] Make the Discord messages more festive --- .github/workflows/aur-release.yml | 8 ++++---- .github/workflows/discord-pr-merged.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/aur-release.yml b/.github/workflows/aur-release.yml index 3d09be9..72c4236 100644 --- a/.github/workflows/aur-release.yml +++ b/.github/workflows/aur-release.yml @@ -194,12 +194,12 @@ jobs: payload=$(jq -n --arg version "$VERSION" --arg run "$RUN_URL" '{ username: "Release Alarm πŸ“¦", allowed_mentions: { parse: [] }, - content: "πŸ“¦πŸŽ‰ **Nowa wersja w AUR!** πŸš€", + content: "πŸš¨πŸš¨πŸŽ‰πŸŽŠ **NOWA WERSJA W AUR!** πŸŽŠπŸŽ‰πŸš¨πŸš¨\nπŸ“¦βœ¨πŸ₯³πŸΎ Release poszedΕ‚! 🍾πŸ₯³βœ¨πŸ“¦", embeds: [{ title: ("email-client " + $version), url: "https://aur.archlinux.org/packages/email-client", color: 3066993, - description: "Gotowe do instalacji: `yay -S email-client` πŸ”₯", + description: "πŸŽŠπŸš€ Gotowe do instalacji: `yay -S email-client` πŸ”₯βœ¨πŸŽ‰", fields: [ { name: "πŸ”§ Workflow", value: ("[logi](" + $run + ")"), inline: true } ] @@ -215,12 +215,12 @@ jobs: --arg commit "$COMMIT_URL" --arg sha "${SHORT_SHA:0:7}" --arg version "$VERSION" '{ username: "Release Alarm πŸ“¦", allowed_mentions: { parse: [] }, - content: (if $stage == "CI" then "❌ **CI na main nie przeszΕ‚o**" else "❌ **Release do AUR nie poszedΕ‚**" end), + content: (if $stage == "CI" then "🚨❌🚨 **CI NA MAIN NIE PRZESZŁO** 🚨❌🚨" else "🚨❌🚨 **RELEASE DO AUR NIE POSZEDŁ** 🚨❌🚨" end), embeds: [{ title: ("PadΕ‚o na etapie: " + $stage), url: $run, color: 15158332, - description: "AUR bez zmian. SzczegΓ³Ε‚y w logach workflow πŸ‘†", + description: "🧯 AUR bez zmian. SzczegΓ³Ε‚y w logach workflow πŸ‘†πŸ”", fields: ([ { name: "πŸ“Œ Commit", value: ("[`" + $sha + "`](" + $commit + ")"), inline: true } ] + (if $version != "-" and $version != "" then diff --git a/.github/workflows/discord-pr-merged.yml b/.github/workflows/discord-pr-merged.yml index 537b3a2..a3f6709 100644 --- a/.github/workflows/discord-pr-merged.yml +++ b/.github/workflows/discord-pr-merged.yml @@ -48,13 +48,13 @@ jobs: '{ username: "Merge Alarm 🚨", allowed_mentions: { parse: [] }, - content: "πŸš¨πŸŽ‰ **Nowy merge do main!** πŸŽŠπŸš€", + content: "πŸš¨πŸš¨πŸŽ‰πŸŽŠ **NOWY MERGE DO MAIN!** πŸŽŠπŸŽ‰πŸš¨πŸš¨\n✨πŸ₯³πŸΎ Leci na produkcjΔ™! 🍾πŸ₯³βœ¨", embeds: [{ title: ("#" + $number + " " + $title), url: $url, color: 16766720, author: { name: $author, icon_url: $avatar }, - description: ("πŸ₯³ Brawo, **" + $author + "**! Kod juΕΌ na `main` πŸ”₯"), + description: ("πŸŽ‰πŸŽŠ Brawo, **" + $author + "**! Kod juΕΌ na `main` πŸ”₯πŸš€βœ¨"), fields: [ { name: "🌿 Branch", value: ("`" + $branch + "`"), inline: true }, { name: "βœ… ZmergowaΕ‚(a)", value: $merged_by, inline: true },