make the build work step 22 #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Linux Packages | ||
on: | ||
schedule: | ||
- cron: '25 23 * * *' | ||
push: | ||
branches: [ "master" ] | ||
# Publish semver tags as releases. | ||
tags: [ '*.*' ] | ||
pull_request: | ||
branches: [ "master" ] | ||
env: | ||
DIST: el9 | ||
ARCH: noarch | ||
jobs: | ||
build_tarball: | ||
name: Build source archive | ||
runs-on: ubuntu-latest | ||
outputs: | ||
ver: ${{ steps.ver.outputs.VERSION }} | ||
gitdate: ${{ steps.gitdate.outputs.GITDATE }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
# Grab the versionnr to use in the main script | ||
- name: Grab the VERSION number in upgrade-ux main script | ||
id: version | ||
run: | | ||
echo "VERSION=$(grep ^VERSION= opt/upgrade-ux/bin/upgrade-ux | cut -d= -f2)" >> $GITHUB_ENV | ||
- name: Set the DISTVERSION variable | ||
id: distver | ||
run: | | ||
git_date=$(git log -n 1 --format="%ai") | ||
date=$(date --date="$git_date" +%Y%m%d%H%M) | ||
echo "DISTVERSION=$VERSION-git$date" >> $GITHUB_ENV | ||
echo "GITDATE=git$date" >> $GITHUB_ENV | ||
- name: Save the VERSION to GITHUB_OUTPUT to use in job build_rpm | ||
id: ver | ||
run: echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||
- name: Save GITDATE to GITHUB_OUTPUT to use in another job as well | ||
id: gitdate | ||
run: echo "GITDATE=$GITDATE" >> $GITHUB_OUTPUT | ||
- name: Replace version in RPM spec so correct source is downloaded when building RPM | ||
run: | | ||
cd packaging/Linux | ||
sudo apt install -y ksh | ||
make dist | ||
- name: Upload source archive as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: upgrade-ux-${{ env.DISTVERSION }}.tar.gz | ||
path: upgrade-ux-${{ env.DISTVERSION }}.tar.gz | ||
build_rpm: | ||
name: Build .rpm package | ||
needs: build_tarball | ||
runs-on: ubuntu-latest | ||
env: | ||
GITDATE: ${{ needs.build_tarball.outputs.gitdate }} | ||
VERSION: ${{ needs.build_tarball.outputs.ver }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Replace version in RPM spec so correct source is downloaded when building RPM | ||
run: | | ||
cd packaging/Linux | ||
make rpm | ||
- name: Run rpmbuild on RPM spec to produce package | ||
id: rpm | ||
uses: gdha/rpmbuild@main | ||
with: | ||
spec_file: upgrade-ux.spec | ||
- name: Upload .rpm package as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: upgrade-ux-${{ env.VERSION }}-1.${{ env.GITDATE }}.${{ env.DIST }}.${{ env.ARCH }}.rpm | ||
path: rpmbuild/RPMS/${{ env.ARCH }}/*.rpm | ||
build_deb: | ||
name: Build .deb package | ||
needs: build_rpm | ||
needs: build_tarball | ||
runs-on: ubuntu-latest | ||
env: | ||
GITDATE: ${{ needs.build_tarball.outputs.gitdate }} | ||
VERSION: ${{ needs.build_tarball.outputs.ver }} | ||
steps: | ||
- name: Download .rpm artifact | ||
uses: actions/download-artifact@v4 | ||
id: download | ||
with: | ||
name: upgrade-ux-${{ env.DISTVERSION }}-1.${{ env.DIST }}.${{ env.ARCH }}.rpm | ||
- name: find . | ||
run: find . | ||
- name: Convert .rpm to .deb | ||
run: | | ||
sudo apt install -y alien | ||
sudo alien -k --verbose --to-deb *.rpm | ||
- name: find . | ||
run: find . -exec readlink -f {} \; | ||
- name: Upload .deb package as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: upgrade-ux-${{ env.DISTVERSION }}-1.${{ env.DIST }}.${{ env.ARCH }}.deb | ||
path: upgrade-ux*.deb | ||
release: | ||
name: Create release with all assets | ||
needs: [build_tarball, build_rpm, build_deb] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download .rpm artifact | ||
uses: actions/download-artifact@v4 | ||
- name: find . | ||
run: find . | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
upgrade-ux-${{ env.DISTVERSION }}.tar.gz/*.tar.gz | ||
upgrade-ux-${{ env.DISTVERSION }}-1.${{ env.DIST }}.${{ env.ARCH }}.rpm/**/*.rpm | ||
upgrade-ux-${{ env.DISTVERSION }}-1.${{ env.DIST }}.${{ env.ARCH }}.deb/**/*.deb |