Skip to content

Commit 6924d67

Browse files
pbrezinaalexey-tikhonov
authored andcommitted
ci: add automation for creating new release
This automation can be manually triggered in "Actions" tab. - update translations - bump version number - create signed commits and tag - push the content to upstream repository - create new github release with autogenerated release notes Since release notes generated from out commit messages are not yet supported, the release is created as a draft. When created, we need to updated release notes manually and then publish the release. Reviewed-by: Alexey Tikhonov <atikhono@redhat.com> Reviewed-by: Justin Stephenson <jstephen@redhat.com>
1 parent c6d1d69 commit 6924d67

File tree

3 files changed

+159
-20
lines changed

3 files changed

+159
-20
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
name: 'Install dependencies'
22
description: 'Install dependencies to build sssd'
3+
inputs:
4+
working-directory:
5+
description: Working directory.
6+
required: false
7+
default: '.'
38
runs:
49
using: "composite"
510
steps:
611
- shell: bash
12+
working-directory: ${{ inputs.working-directory }}
713
run: |
814
sudo ./contrib/ci/run --deps-only

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "release"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
description: 'Target branch for release'
7+
required: true
8+
default: 'master'
9+
type: string
10+
version:
11+
description: 'Release version'
12+
required: true
13+
type: string
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
container: quay.io/sssd/ci-client-devel:latest
18+
permissions:
19+
contents: write
20+
pull-requests: read
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
path: sssd
26+
27+
- name: Import GPG key
28+
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec
29+
with:
30+
gpg_private_key: ${{ secrets.GPG_KEY }}
31+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
32+
git_config_global: true
33+
git_user_signingkey: true
34+
git_tag_gpgsign: true
35+
git_commit_gpgsign: true
36+
git_committer_name: sssd-bot
37+
git_committer_email: sssd-maintainers@lists.fedoraproject.org
38+
39+
- name: Install dependencies
40+
uses: ./sssd/.github/actions/install-dependencies
41+
with:
42+
working-directory: sssd
43+
44+
- name: Execute release script
45+
working-directory: sssd
46+
shell: bash
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
./scripts/release.sh "${{ inputs.branch }}" "${{ inputs.version }}"

scripts/release.sh

Lines changed: 103 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,112 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3-
function config()
4-
{
5-
autoreconf -i -f || return $?
6-
./configure
3+
set -e
4+
5+
# Group output in Github Job view
6+
function GROUP_START() {
7+
echo "::group::$1"
8+
}
9+
10+
function GROUP_END() {
11+
echo "::endgroup::"
712
}
813

9-
SAVED_PWD=$PWD
10-
version=`grep '\[VERSION_NUMBER], \[.*\]' version.m4 | grep '[0-9]\+\.[0-9]\+\.[0-9]\+\(-[^]]\+\)\?' -o`
11-
tag=${version}
14+
# Usage
15+
if [ "$#" -ne 2 ] && [ "$#" -ne 4 ]; then
16+
echo "Usage: $0 <branch> <version> [<github-repo> <git-remote>]" >&2
17+
exit 1
18+
fi
19+
20+
tmpdir=$(mktemp -d)
21+
scriptdir=`realpath \`dirname "$0"\``
22+
rootdir=`realpath "$scriptdir/.."`
23+
branch=$1
24+
version=$2
25+
github_repo="${3:-SSSD/sssd}"
26+
git_remote="${4:-origin}"
27+
28+
echo "SSSD sources location: $rootdir"
29+
echo "Repository: $github_repo"
30+
echo "Remote: $git_remote"
31+
echo "Temporary directory: $tmpdir"
32+
echo "Target branch: $branch"
33+
echo "Released version: $version"
1234

13-
trap "cd $SAVED_PWD; rm -rf sssd-${version} sssd-${version}.tar" EXIT
35+
# Work in a temporary copy of the repository
36+
pushd $tmpdir
37+
trap 'rm -rf "$tmpdir"; popd' EXIT
38+
cp -a "$rootdir/." "$tmpdir"
1439

15-
git archive --format=tar --prefix=sssd-${version}/ ${tag} > sssd-${version}.tar
16-
if [ $? -ne 0 ]; then
17-
echo "Cannot perform git-archive, check if tag $tag is present in git tree"
40+
GROUP_START "Check prerequisites"
41+
# Check if required commands are installed
42+
for cmd in git gh autoreconf make sed gpg; do
43+
if ! command -v "$cmd" &> /dev/null; then
44+
echo "Error: Required command '$cmd' is not installed." >&2
1845
exit 1
46+
fi
47+
done
48+
49+
# Check if there are any opened weblate pull requests
50+
if [ -n "$(gh pr list --author weblate --state open --base \"$branch\" --repo \"$github_repo\")" ]; then
51+
echo "Error: There are open weblate pull-requests, please merge them first." >&2
52+
exit 1
53+
fi
54+
55+
# Check if repository is pristine
56+
if [ -n "$(git status --porcelain)" ]; then
57+
echo "Error: SSSD sources have uncommitted changes." >&2
58+
exit 1
1959
fi
20-
tar xf sssd-${version}.tar
60+
GROUP_END
61+
62+
set -x
63+
64+
GROUP_START "Checkout branch"
65+
git checkout "$branch"
66+
git pull --rebase
67+
GROUP_END
68+
69+
GROUP_START "Configure SSSD"
70+
autoreconf -if
71+
./configure
72+
GROUP_END
73+
74+
GROUP_START "Update translations"
75+
make update-po
76+
git add po/ src/man/po/
77+
git commit -S -m "pot: update pot files"
78+
GROUP_END
79+
80+
GROUP_START "Commit and tag release"
81+
# Set release version (allow empty commit in case it was already set)
82+
sed -i -E "s/(.+VERSION_NUMBER.+)\\[.+\\](.+)/\1[$version]\2/" version.m4
83+
git add version.m4
84+
git commit -S -m "Release sssd-$version" --allow-empty
85+
git tag -s "$version" -m "Release sssd-$version"
86+
GROUP_END
87+
88+
GROUP_START "Create tarball"
89+
make dist-gzip
90+
GROUP_END
91+
92+
GROUP_START "Sign tarball"
93+
gpg --default-key C13CD07FFB2DB1408E457A3CD3D21B2910CF6759 --detach-sign --armor "sssd-${version}.tar.gz"
94+
sha256sum "sssd-${version}.tar.gz" > "sssd-${version}.tar.gz.sha256sum"
95+
GROUP_END
2196

22-
pushd sssd-${version}
23-
config || exit 1
24-
make dist-gzip || exit 1 # also builds docs
25-
popd
97+
GROUP_START "Push commits and tag"
98+
git push "$git_remote" "$branch"
99+
git push "$git_remote" "$version"
100+
GROUP_END
26101

27-
mv sssd-${version}/sssd-${version}.tar.gz .
28-
gpg2 --default-key C13CD07FFB2DB1408E457A3CD3D21B2910CF6759 --detach-sign --armor sssd-${version}.tar.gz
29-
sha256sum sssd-${version}.tar.gz > sssd-${version}.tar.gz.sha256sum
102+
GROUP_START "Create GitHub release"
103+
gh release create "$version" \
104+
--repo "$github_repo" \
105+
--title "sssd-$version" \
106+
--generate-notes \
107+
--verify-tag \
108+
--draft \
109+
"sssd-${version}.tar.gz" \
110+
"sssd-${version}.tar.gz.asc" \
111+
"sssd-${version}.tar.gz.sha256sum"
112+
GROUP_END

0 commit comments

Comments
 (0)