diff --git a/.github/workflows/releasebuild.yml b/.github/workflows/releasebuild.yml new file mode 100644 index 00000000..92d41c77 --- /dev/null +++ b/.github/workflows/releasebuild.yml @@ -0,0 +1,88 @@ +--- +name: releasebuild + +on: + release: + types: + - published + +jobs: + + distbuild: + name: Checkout code and build tar.gz + runs-on: ubuntu-latest + steps: + - name: Set the version + id: version_number + run: | + echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + - name: Set the git source location + id: source_loc + run: | + echo "SRC=${GITHUB_REF}" >> $GITHUB_ENV + - name: Checkout Code + uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Build tar.gz + run: make dist + - name: Upload mock script + uses: actions/upload-artifact@v2 + with: + name: mockbuild.sh + path: ci/mockbuild.sh + - name: Upload tar.gz + uses: actions/upload-artifact@v2 + with: + name: warewulf-${{ env.VERSION }}.tar.gz + path: warewulf-${{ env.VERSION }}.tar.gz + + rpmbuild: + name: Build using Rocky Linux + needs: distbuild + runs-on: ubuntu-latest + container: + image: rockylinux/rockylinux + options: --privileged + steps: + - name: Set the version + id: version_number + run: | + echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + - name: Download mock build script + uses: actions/download-artifact@v2 + with: + name: mockbuild.sh + - name: Download tar.gz + uses: actions/download-artifact@v2 + with: + name: warewulf-${{ env.VERSION }}.tar.gz + - name: Set execute bit + run: chmod +x mockbuild.sh + - name: Run rpm build script + run: ./mockbuild.sh ${{ env.VERSION }} + - name: Upload EL8 RPM + uses: actions/upload-artifact@v2 + with: + name: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el8.x86_64.rpm + path: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el8.x86_64.rpm + - name: Upload EL7 RPM + uses: actions/upload-artifact@v2 + with: + name: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el7.x86_64.rpm + path: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el7.x86_64.rpm + - name: Upload Assets To Release + uses: xresloader/upload-to-github-release@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: 'warewulf-${{ env.VERSION }}.tar.gz;warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.*.rpm' + draft: false + update_latest_release: true + tags: true diff --git a/Makefile b/Makefile index f88cc2db..3903dab4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ .PHONY: all -VERSION := 4.2.0 +VERSION ?= 4.2.0 +RELEASE ?= 1 + +SRC ?= main # auto installed tooling TOOLS_DIR := .tools @@ -134,9 +137,9 @@ man_page: dist: vendor rm -rf _dist/warewulf-$(VERSION) mkdir -p _dist/warewulf-$(VERSION) - git archive --format=tar main | tar -xf - -C _dist/warewulf-$(VERSION) + git archive --format=tar $(SRC) | tar -xf - -C _dist/warewulf-$(VERSION) cp -r vendor _dist/warewulf-$(VERSION)/ - sed -e 's/@VERSION@/$(VERSION)/g' warewulf.spec.in > _dist/warewulf-$(VERSION)/warewulf.spec + sed -e 's/@VERSION@/$(VERSION)/g; s/@RELEASE@/$(RELEASE)/g' warewulf.spec.in > _dist/warewulf-$(VERSION)/warewulf.spec cd _dist; tar -czf ../warewulf-$(VERSION).tar.gz warewulf-$(VERSION) clean: diff --git a/ci/mockbuild.sh b/ci/mockbuild.sh new file mode 100644 index 00000000..1547310a --- /dev/null +++ b/ci/mockbuild.sh @@ -0,0 +1,17 @@ +#!/usr/bin/bash + +VERSION=$1 + +dnf install -y epel-release +dnf install -y mock + +tar -xf warewulf-${VERSION}.tar.gz warewulf-${VERSION}/warewulf.spec + +RELEASE=$(grep 'Release: ' warewulf-${VERSION}/warewulf.spec | cut -d ':' -f2 | awk -F'%' '{print $1}' | tr -d ' ') +echo RELEASE=${RELEASE} >> $GITHUB_ENV + +mock -r epel-8-x86_64 --rebuild --spec=warewulf-${VERSION}/warewulf.spec --sources=. +mv /var/lib/mock/epel-8-x86_64/result/warewulf-${VERSION}-${RELEASE}.el8.x86_64.rpm . + +mock -r epel-7-x86_64 --rebuild --spec=warewulf-${VERSION}/warewulf.spec --sources=. +mv /var/lib/mock/epel-7-x86_64/result/warewulf-${VERSION}-${RELEASE}.el7.x86_64.rpm . \ No newline at end of file diff --git a/warewulf.spec.in b/warewulf.spec.in index 0a9e877b..19c4a637 100644 --- a/warewulf.spec.in +++ b/warewulf.spec.in @@ -5,7 +5,7 @@ Name: warewulf Summary: A provisioning system for large clusters of bare metal and/or virtual systems Version: @VERSION@ -Release: 1%{?dist} +Release: @RELEASE@%{?dist} License: BSD-3-Clause URL: https://github.com/hpcng/warewulf Source: https://github.com/hpcng/warewulf/archive/refs/tags/v%{version}.tar.gz