Skip to content

Commit

Permalink
build: Release build automation ([ElementsProject#7776]).
Browse files Browse the repository at this point in the history
Changelog-None
  • Loading branch information
s373nZ committed Nov 7, 2024
1 parent 183da39 commit 72ace35
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# https://docs.corelightning.org/docs/release-checklist
name: "Release 🚀"
on:
push:
# TODO: Remove after testing.
branches:
- 7776-release-builds-automation
tags:
- 'v[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+[0-9a-z]+'
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-24.04
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Validate release
run: tools/check-release.sh

# tools/build-release.sh requires lowdown
- name: Prepare base environment
run: |
sudo apt-get install -y lowdown
./configure
- name: Build environment setup
run: contrib/cl-repro.sh

- name: Build release
run: tools/build-release.sh bin-Fedora-28-amd64 bin-Ubuntu

- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
path: release/
if-no-files-found: error
2 changes: 1 addition & 1 deletion tools/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ for target in $TARGETS; do
# Capitalize the first letter of distro
D=$(echo "$d" | awk '{print toupper(substr($0,1,1))substr($0,2)}')
echo "Building Ubuntu $D Image"
docker run --rm -v "$(pwd)":/repo -e FORCE_MTIME="$MTIME" -e FORCE_VERSION="$VERSION" -ti cl-repro-"$d"
docker run --rm -v "$(pwd)":/repo -e FORCE_MTIME="$MTIME" -e FORCE_VERSION="$VERSION" cl-repro-"$d"
echo "Ubuntu $D Image Built"
done
;;
Expand Down
55 changes: 55 additions & 0 deletions tools/check-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#! /bin/bash

set -e

# Git release tag checks and validation, to catch common release
# tagging issues prior to build via Github Actions.
#
# 1. The tag should point to the HEAD of the branch.
# - tools/build-release.sh#67
# 2. The pushed tag should match the branch tag at the HEAD.
# 3. The CHANGELOG.md contains a header entry for the version tag.
# 4. The CHANGELOG.md entry for that version tag can be parsed for a date.

echo "GITHUB_REF_TYPE=$GITHUB_REF_TYPE"
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"

# The tag should point to the HEAD of the branch.
VERSION=$(git tag --points-at HEAD)
echo "VERSION=$VERSION"
if [ "$VERSION" = "" ]; then
echo "No tagged version at HEAD?" >&2
exit 1
fi

if [ "$GITHUB_REF_TYPE" = "tag" ]; then
# The pushed tag should match the branch tag at the HEAD.
if [ "$VERSION" != "$GITHUB_REF_NAME" ]; then
echo "The pushed tag must match the version tag." >&2
exit 1
fi

# The pushed tag should match the `make version` target output.
MAKE_VERSION=$(make version)
echo "MAKE_VERSION=$MAKE_VERSION"
if [ "$MAKE_VERSION" != "$GITHUB_REF_NAME" ]; then
echo "The pushed tag must match the `make version` target output." >&2
exit 1
fi
fi

# The CHANGELOG.md contains a header entry for the version tag.
CHANGELOG_TITLE=$(grep "## \[${VERSION#v}\]" CHANGELOG.md)
if [ $? != 0 ]; then
echo "No entry in the CHANGELOG.md found for $VERSION." >&2
exit 1
fi
echo "CHANGELOG_TITLE=$CHANGELOG_TITLE"

# The CHANGELOG.md entry for that version tag can be parsed for a date.
RELEASE_DATE=$(sed -n "s/^## \\[.*${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)
echo "RELEASE_DATE=$RELEASE_DATE"
if [ "$RELEASE_DATE" = "" ]; then
echo "The release title in CHANGELOG.md cannot be parsed for a date." >&2
exit 1
fi

0 comments on commit 72ace35

Please sign in to comment.