Trigger on Tue Nov 5 02:49:22 UTC 2024 #1357
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 Opencast Testing RPMs | |
env: | |
arch: noarch | |
repo: testing | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '30 2 * * *' | |
push: | |
branches: | |
- develop | |
- 'r/*' | |
paths: | |
- .trigger | |
- oc.version | |
- branch.version | |
- .github/workflows/build-opencast-testing.yml | |
- rpmbuild/SOURCES/* | |
- rpmbuild/SPECS/opencast.spec | |
jobs: | |
build: | |
strategy: | |
matrix: | |
osversion: | |
- 8 | |
- 9 | |
outputs: | |
oc-version: ${{ steps.version.outputs.version }} | |
arch: ${{ env.arch }} | |
repo: ${{ env.repo }} | |
new: ${{ steps.version-check.outputs.new }} | |
name: build (el${{ matrix.osversion }}) | |
runs-on: ubuntu-latest | |
container: | |
image: docker.io/lkiesow/opencast-rpmbuild:el${{ matrix.osversion }}-oc16 | |
steps: | |
- uses: actions/checkout@v3 | |
- id: version | |
run: echo "version=$(cat oc.version)" >> $GITHUB_OUTPUT | |
- name: clone opencast | |
run: | | |
git clone --branch "$(cat branch.version)" --depth 1 https://github.com/opencast/opencast.git | |
- name: check if new version exists | |
id: version-check | |
working-directory: opencast | |
env: | |
S3_HOST: ${{ secrets.S3_HOST }} | |
run: | | |
curl -sO https://${S3_HOST}/opencast-pkg/rpms/${{ env.repo }}/el/${{ matrix.osversion }}/oc-${{ steps.version.outputs.version }}/${{ env.arch }}/latest.commit | |
git rev-parse HEAD > current.commit | |
if diff -q latest.commit current.commit; then | |
echo "Commit $(cat current.commit) already built" | |
echo "new=no" >> "$GITHUB_OUTPUT" | |
else | |
echo "Last built $(cat latest.commit). Building new commit $(cat current.commit)" | |
echo "new=yes" >> "$GITHUB_OUTPUT" | |
fi | |
- name: cache local maven repository | |
if: steps.version-check.outputs.new == 'yes' | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: clone mvn.opencast.org | |
if: steps.version-check.outputs.new == 'yes' | |
run: | | |
git clone --depth 1 https://github.com/opencast/mvn.opencast.org.git | |
- name: prepare additional maven repository | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: opencast | |
run: | | |
sed -i "s#https://mvn.opencast.org/#file://$(readlink -f ../mvn.opencast.org)#" pom.xml | |
- name: build opencast | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: opencast | |
run: > | |
mvn | |
--batch-mode | |
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120 | |
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | |
-Dcheckstyle.skip=true | |
-DskipTests | |
clean install | |
- name: list distributions to build | |
if: steps.version-check.outputs.new == 'yes' | |
run: | | |
find opencast/build/ -type f -name 'opencast-dist-*gz' \ | |
| sed 's/^.*opencast-dist-\([^-]*\)-.*$/\1/' \ | |
| tee rpmbuild/SPECS/dists | |
- name: mimic rpmdev-setuptree | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: rpmbuild | |
run: | | |
ln -s "$(pwd)" ~/rpmbuild | |
- name: move build artifacts | |
if: steps.version-check.outputs.new == 'yes' | |
run: | | |
mv -v opencast/build/opencast-dist-*.tar.gz rpmbuild/SOURCES/ | |
- name: define rpm version | |
if: steps.version-check.outputs.new == 'yes' | |
run: | | |
echo "%octarversion ${{ steps.version.outputs.version }}-SNAPSHOT" >> ~/.rpmmacros | |
echo "%ocversion ${{ steps.version.outputs.version }}" >> ~/.rpmmacros | |
echo "%ocrelease 0.$(date +%Y%m%d%H%M%S)" >> ~/.rpmmacros | |
- name: build rpm | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: rpmbuild/SPECS | |
run: | | |
for dist in $(cat dists); do | |
rpmbuild -ba -D "ocdist ${dist}" opencast.spec | |
done | |
- name: list rpms | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: rpmbuild/RPMS/${{ env.arch }} | |
run: | | |
du -hs ./*.rpm | |
- name: prepare gpg | |
if: steps.version-check.outputs.new == 'yes' | |
env: | |
GPG_KEY: ${{ secrets.GPG_KEY_OC16 }} | |
run: | | |
echo "${GPG_KEY}" | gpg --import | |
echo '%_gpg_name [email protected]' >> ~/.rpmmacros | |
- name: sign rpms | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: rpmbuild/RPMS/${{ env.arch }} | |
run: | | |
rpmsign --addsign *.rpm | |
- uses: lkiesow/configure-s3cmd@v1 | |
if: steps.version-check.outputs.new == 'yes' | |
with: | |
host: ${{ secrets.S3_HOST }} | |
access_key: ${{ secrets.S3_ACCESS_KEY }} | |
secret_key: ${{ secrets.S3_SECRET_KEY }} | |
- name: publish repository rpm | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: rpmbuild/RPMS/${{ env.arch }} | |
run: | | |
s3cmd put -P *.rpm "s3://opencast-pkg/rpms/${{ env.repo }}/el/${{ matrix.osversion }}/oc-${{ steps.version.outputs.version }}/${{ env.arch }}/" | |
# keep latest 14 * 6 = 84 builds | |
- name: remove old builds | |
if: steps.version-check.outputs.new == 'yes' | |
run: | | |
s3cmd ls "s3://opencast-pkg/rpms/${{ env.repo }}/el/${{ matrix.osversion }}/oc-${{ steps.version.outputs.version }}/${{ env.arch }}/opencast-" |\ | |
sort |\ | |
head -n -84 |\ | |
sed 's_^.*s3://_s3://_' |\ | |
while read i | |
do | |
s3cmd del "$i"; | |
done | |
- name: keep track of latest build | |
if: steps.version-check.outputs.new == 'yes' | |
working-directory: opencast | |
run: | | |
s3cmd put -P current.commit "s3://opencast-pkg/rpms/${{ env.repo }}/el/${{ matrix.osversion }}/oc-${{ steps.version.outputs.version }}/${{ env.arch }}/latest.commit" | |
createrepo: | |
uses: opencast/opencast-rpmbuild/.github/workflows/createrepo.yml@develop | |
if: ${{ needs.build.outputs.new == 'yes' }} | |
needs: build | |
strategy: | |
matrix: | |
os-version: | |
- 8 | |
- 9 | |
with: | |
oc-version: ${{ needs.build.outputs.oc-version }} | |
os-version: ${{ matrix.os-version }} | |
arch: ${{ needs.build.outputs.arch }} | |
repo: ${{ needs.build.outputs.repo }} | |
secrets: | |
S3_HOST: ${{ secrets.S3_HOST }} | |
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} |