From 8bf8f189629e24d2aff6a67a3feef8f0f4e86c3e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 2 Dec 2023 21:45:12 -0800 Subject: [PATCH] trigger Fedora COPR build from GitHub Signed-off-by: Dirk Hohndel --- .github/workflows/fedora-copr-build.yml | 50 +++++++++++++++++++++++++ packaging/copr/config.copr | 6 +++ packaging/copr/make-package.sh | 25 ++++++++----- 3 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/fedora-copr-build.yml create mode 100644 packaging/copr/config.copr diff --git a/.github/workflows/fedora-copr-build.yml b/.github/workflows/fedora-copr-build.yml new file mode 100644 index 000000000..01015b6b3 --- /dev/null +++ b/.github/workflows/fedora-copr-build.yml @@ -0,0 +1,50 @@ +name: Fedora Copr Build +on: + push: + branches: + - master + - github-action-test + pull_request: + branches: + - master + +jobs: + setup-build: + name: Submit build to Fedora COPR + # this seems backwards, but we want to run under Fedora, but Github doesn' support that + container: fedora:latest + runs-on: ubuntu-latest + + steps: + - name: Check out sources + uses: actions/checkout@v1 + + - name: Setup API token for copr-cli + env: + API_TOKEN: ${{ secrets.COPR_TOKEN }} + API_LOGIN: ${{ secrets.COPR_LOGIN }} + run: | + mkdir -p "$HOME/.config" + cp packaging/copr/config.copr "$HOME/.config/copr" + sed -i "s/API_TOKEN/$API_TOKEN/;s/API_LOGIN/$API_LOGIN/" "$HOME/.config/copr" + + - name: Setup build dependencies in the Fedora container + run: | + dnf -y install @development-tools @rpm-development-tools + dnf -y install copr-cli make + + - name: setup git + run: | + git config --global --add safe.directory /__w/subsurface/subsurface + git config --global --add safe.directory /__w/subsurface/subsurface/libdivecomputer + + - name: Checkout googlemaps + run: | + cd .. + git clone https://github.com/subsurface/googlemaps + + - name: run the copr build script + run: | + cd .. + bash -x subsurface/packaging/copr/make-package.sh post + diff --git a/packaging/copr/config.copr b/packaging/copr/config.copr new file mode 100644 index 000000000..410619273 --- /dev/null +++ b/packaging/copr/config.copr @@ -0,0 +1,6 @@ +[copr-cli] +login = API_LOGIN +username = dirkhh +token = API_TOKEN +copr_url = https://copr.fedorainfracloud.org +# expiration date: 2024-05-31 diff --git a/packaging/copr/make-package.sh b/packaging/copr/make-package.sh index 175959652..a270f73f5 100644 --- a/packaging/copr/make-package.sh +++ b/packaging/copr/make-package.sh @@ -9,7 +9,7 @@ # to make changes as they can't write to the OBS/COPR repos that I own... but this should be a great # starting point. -if [[ $(pwd | grep "subsurface$") || ! -d subsurface || ! -d subsurface/libdivecomputer ]] ; then +if [[ ! -d subsurface || ! -d subsurface/libdivecomputer ]] ; then echo "Please start this script from the folder ABOVE the subsurface source directory" exit 1; fi @@ -19,6 +19,8 @@ if [[ ! -d googlemaps ]] ; then exit 1; fi +TOPDIR=$(pwd) + # ensure that the libdivecomputer module is there and current cd subsurface git submodule init @@ -34,18 +36,21 @@ FOLDER="subsurface-$VERSION" echo "building Subsurface" $VERSION "with libdivecomputer" $LIBDCREVISION -# we put all of the files into the distrobuilds directory in order not to clutter the 'src' directory -mkdir -p distrobuilds -cd distrobuilds +# create the file system structure that the rpmbuild tools expect +rpmdev-setuptree + +# in order for the tools to work as expected, let's run this from the HOME directory +cd $HOME if [[ ! -d $FOLDER ]]; then mkdir $FOLDER echo "copying sources" - (cd ../subsurface ; tar cf - . ) | (cd $FOLDER ; tar xf - ) + (cd "$TOPDIR"/subsurface ; tar cf - . ) | (cd $FOLDER ; tar xf - ) cd $FOLDER - cp -a ../../googlemaps . + cp -a "$TOPDIR"/googlemaps . + # make sure we only have the files we want (the builds should all be empty when running on GitHub) rm -rf .git libdivecomputer/.git googlemaps/.git build build-mobile libdivecomputer/build googlemaps/build echo $GITVERSION > .gitversion echo $GITDATE > .gitdate @@ -73,11 +78,11 @@ if [[ "$1" = "post" ]] ; then DESCRIPTION="This is the official Subsurface build, provided by the Subsurface team, including our own custom libdivecomputer." else REPO="Subsurface-test" - SUMMARY="test build of the latest development version of Subsurface" - DESCRIPTION="This is a test build of Subsurface, provided by the Subsurface team, based on the latest sources. Only use if you need the bleeding edge of development." + SUMMARY="rolling build of the latest development version of Subsurface" + DESCRIPTION="This is a 'daily' build of Subsurface, provided by the Subsurface team, based on the latest sources. The builds aren't always well tested." fi - cd rpmbuild - cat ../../subsurface/packaging/copr/subsurface.spec | sed "s/%define latestVersion.*/%define latestVersion $VERSION/;s/DESCRIPTION/$DESCRIPTION/;s/SUMMARY/$SUMMARY/" > SPECS/subsurface.spec + cd "$HOME"/rpmbuild + cat "$TOPDIR"/subsurface/packaging/copr/subsurface.spec | sed "s/%define latestVersion.*/%define latestVersion $VERSION/;s/DESCRIPTION/$DESCRIPTION/;s/SUMMARY/$SUMMARY/" > SPECS/subsurface.spec rpmbuild --verbose -bs $(pwd)/SPECS/subsurface.spec copr build --nowait $REPO $(pwd)/SRPMS/subsurface-$VERSION-1.fc*.src.rpm fi