diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..282a4143 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,123 @@ +--- +name: release + +on: + release: + types: + - published + +jobs: + dist: + name: Checkout code and build warewulf.spec and dist + runs-on: ubuntu-latest + steps: + - name: Set DIST + run: | + echo "DIST=warewulf-${GITHUB_REF#refs/tags/v}.tar.gz" >> $GITHUB_ENV + + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Build spec and dist + run: | + make warewulf.spec dist + + - name: Upload warewulf.spec + uses: actions/upload-artifact@v3 + with: + name: warewulf.spec + path: warewulf.spec + + - name: Upload DIST + uses: actions/upload-artifact@v3 + with: + name: ${{ env.DIST }} + path: ${{ env.DIST }} + + - name: Attach DIST to release + uses: xresloader/upload-to-github-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_id: ${{ github.event.release.id }} + file: ${{ env.DIST }} + + rpm: + name: Build RPMs + needs: dist + runs-on: ubuntu-latest + container: + image: rockylinux/rockylinux:9 + options: --privileged + strategy: + fail-fast: false + matrix: + include: + - target: rocky+epel-8-x86_64 + arch: x86_64 + dist: el8 + - target: rocky+epel-9-x86_64 + arch: x86_64 + dist: el9 + - target: centos+epel-7-x86_64 + arch: x86_64 + dist: el7 + - target: opensuse-leap-15.5-x86_64 + arch: x86_64 + dist: suse.lp155 + steps: + - name: Install EPEL + run: dnf -y install epel-release + + - name: Install mock and rpm-build + run: | + dnf -y install mock rpm-build + echo "config_opts['print_main_output'] = True" >>/etc/mock/site-defaults.cfg + + - name: Download spec + uses: actions/download-artifact@v3 + with: + name: warewulf.spec + + - name: Set the expected version + run: | + echo "EXPECTED_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + + - name: Download dist + uses: actions/download-artifact@v3 + with: + name: warewulf-${{ env.EXPECTED_VERSION }}.tar.gz + + - name: Set RPM and SRPM + run: | + VERSION=$(rpm -q --qf "%{VERSION}\n" --specfile warewulf.spec) + GENERIC_RELEASE=$(rpm -q --qf "%{RELEASE}\n" --specfile warewulf.spec | cut -d. -f1-2) + RPM=warewulf-${VERSION}-${GENERIC_RELEASE}.${{ matrix.dist }}.${{ matrix.arch }}.rpm + SRPM=warewulf-${VERSION}-${GENERIC_RELEASE}.${{ matrix.dist }}.src.rpm + echo "RPM=${RPM}" >> $GITHUB_ENV + echo "SRPM=${SRPM}" >> $GITHUB_ENV + + - name: Build RPMs and run tests + run: | + mock -r ${{ matrix.target }} --rebuild --spec=warewulf.spec --sources=. + mock -r ${{ matrix.target }} --chroot -- make -C /builddir/build/BUILD/warewulf-${{ env.EXPECTED_VERSION }} test + + - name: Upload RPM + uses: actions/upload-artifact@v3 + with: + name: ${{ env.RPM }} + path: /var/lib/mock/${{ matrix.target }}/result/${{ env.RPM }} + + - name: Upload SRPM + uses: actions/upload-artifact@v3 + with: + name: ${{ env.SRPM }} + path: /var/lib/mock/${{ matrix.target }}/result/${{ env.SRPM }} + + - name: Attach RPM and SRPM to release + uses: xresloader/upload-to-github-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_id: ${{ github.event.release.id }} + file: "/var/lib/mock/${{ matrix.target }}/result/${{ env.RPM }};/var/lib/mock/${{ matrix.target }}/result/${{ env.SRPM }}" diff --git a/.github/workflows/releasebuild.yml b/.github/workflows/releasebuild.yml deleted file mode 100644 index c0841b9b..00000000 --- a/.github/workflows/releasebuild.yml +++ /dev/null @@ -1,116 +0,0 @@ ---- -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@v3 - - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: '1.16' - cache: true - - - name: Build tar.gz - run: make dist - - - name: Upload mock script - uses: actions/upload-artifact@v3 - with: - name: mockbuild.sh - path: ci/mockbuild.sh - - - name: Upload tar.gz - uses: actions/upload-artifact@v3 - 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@v3 - with: - name: mockbuild.sh - - - name: Download tar.gz - uses: actions/download-artifact@v3 - 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 RPMs - uses: actions/upload-artifact@v3 - with: - name: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el8 - path: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el8.*.rpm - - - name: Upload EL7 RPMs - uses: actions/upload-artifact@v3 - with: - name: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el7 - path: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.el7.*.rpm - - - name: Upload openSUSE Leap 15.3 RPMs - uses: actions/upload-artifact@v3 - with: - name: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.suse.lp153 - path: warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.suse.lp153.*.rpm - - - name: Upload Assets To Release - if: "!github.event.release.prerelease" - uses: xresloader/upload-to-github-release@v1 - 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 - - - name: Upload Assets To Pre-Release - if: "github.event.release.prerelease" - uses: xresloader/upload-to-github-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - file: 'warewulf-${{ env.VERSION }}.tar.gz;warewulf-${{ env.VERSION }}-${{ env.RELEASE }}.*.rpm' - draft: false - update_latest_release: false - prerelease: true - tags: true diff --git a/ci/mockbuild.sh b/ci/mockbuild.sh deleted file mode 100644 index c068d71d..00000000 --- a/ci/mockbuild.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 rocky+epel-8-x86_64 --rebuild --spec=warewulf-${VERSION}/warewulf.spec --sources=. -mv /var/lib/mock/rocky+epel-8-x86_64/result/warewulf-${VERSION}-${RELEASE}.el8.x86_64.rpm . -mv /var/lib/mock/rocky+epel-8-x86_64/result/warewulf-${VERSION}-${RELEASE}.el8.src.rpm . - -mock -r centos+epel-7-x86_64 --rebuild --spec=warewulf-${VERSION}/warewulf.spec --sources=. -mv /var/lib/mock/centos+epel-7-x86_64/result/warewulf-${VERSION}-${RELEASE}.el7.x86_64.rpm . -mv /var/lib/mock/centos+epel-7-x86_64/result/warewulf-${VERSION}-${RELEASE}.el7.src.rpm . - -mock -r opensuse-leap-15.3-x86_64 --rebuild --spec=warewulf-${VERSION}/warewulf.spec --sources=. -mv /var/lib/mock/opensuse-leap-15.3-x86_64/result/warewulf-${VERSION}-${RELEASE}.suse.lp153.x86_64.rpm . -mv /var/lib/mock/opensuse-leap-15.3-x86_64/result/warewulf-${VERSION}-${RELEASE}.suse.lp153.src.rpm .