Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework DEB build script and actions/upload steps. #196

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 48 additions & 15 deletions .github/workflows/ci-deb-packages-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,50 +45,83 @@ jobs:
fetch-depth: 0

- name: General debs based on ${{ inputs.BASE_IMAGE }} for ${{ inputs.PLATFORM }}
shell: sh
run: |
cat > run.sh <<EOF
mkdir -v -p /tmp/$GITHUB_RUN_ID/

cat << EOF | tee /tmp/$GITHUB_RUN_ID/run.sh
#!/bin/bash

dch -b -M -v "`dpkg-parsechangelog --show-field Version | cut -f1 -d"-"`-$GITHUB_RUN_ID~`echo $GITHUB_SHA | cut -c1-10`~`lsb_release -cs`" --force-distribution -D "`lsb_release -cs`" "Nightly build, `echo $GITHUB_SHA | cut -c1-10`"
debuild -b -us -uc
ls -la ..
mv ../*.deb .
set -o pipefail

# eval inside builder image
version=\$(dpkg-parsechangelog --show-field Version | cut -f1 -d"-")
if [ $? -ne 0 ]; then
exit 1
fi

lsb=\$(lsb_release -cs)
if [ $? -ne 0 ]; then
exit 1
fi

# eval inside runner
hash=$(echo $GITHUB_SHA | cut -c1-10)

# deb package version
dch_version=\${version}-${GITHUB_RUN_ID}~\${hash}~\${lsb}
echo "dch_version: \${dch_version}"

dch -b -M -v "\${dch_version}" --force-distribution -D "\${lsb}" "Nightly build, \${hash}"
if [ $? -ne 0 ]; then
exit 1
fi

debuild -b -us -uc && mv -v ../*.deb .
EOF
chmod +x run.sh

chmod -v +x /tmp/$GITHUB_RUN_ID/run.sh

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: build debs
run: docker run --platform linux/${{inputs.PLATFORM}} --rm --entrypoint="/root/run.sh" -w /root -v $(pwd):/root ${{inputs.BASE_IMAGE}}
run: docker run --platform linux/${{inputs.PLATFORM}} --rm --entrypoint="/usr/local/bin/run.sh" -w /root -v $(pwd):/root -v /tmp/${GITHUB_RUN_ID}/run.sh:/usr/local/bin/run.sh ${{inputs.BASE_IMAGE}}

- name: Set custom variables
shell: sh
run: |
echo image_tag=$(echo ${{inputs.BASE_IMAGE}} | awk -F ':' '{print $2}') >> $GITHUB_ENV
codename=$(echo ${{inputs.BASE_IMAGE}} | awk -F ':' '{print $2}')
echo "IMAGE_TAG=$codename-${{inputs.PLATFORM}}" >> $GITHUB_ENV

- name: Copy git hash
run: echo $GITHUB_SHA > hash.txt
shell: sh
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_SHA: ${{ github.sha }}
run: |
echo $GITHUB_SHA > hash.txt

- name: Compress files
shell: sh
run: |
tar -czvf $image_tag.tar.gz $(ls | grep '.deb\|hash.txt')
tar -czvf ${{ env.IMAGE_TAG }}.tar.gz $(ls -1 | grep '.deb\|hash.txt')

- name: Generate SHA checksum
shell: sh
run: |
sha512sum $image_tag.tar.gz > $image_tag.sha1
sha512sum ${{ env.IMAGE_TAG }}.tar.gz > ${{ env.IMAGE_TAG }}.sha1

- uses: actions/upload-artifact@v4
with:
name: deb-${{inputs.PLATFORM}}-artifact
name: deb-${{ env.IMAGE_TAG }}-artifact
path: |
*.tar.gz
*.sha1

if-no-files-found: error

- uses: actions/upload-artifact@v4
with:
name: deb-changelog-artifact
name: deb-${{ env.IMAGE_TAG }}-changelog-artifact
path: |
./debian/changelog
if-no-files-found: error