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

github CI: nightly builds for multiple distributions #1270

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
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
61 changes: 48 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,61 @@ jobs:
files: coverage.txt

release:
name: release
needs: build
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
name: [Ubuntu-20, Ubuntu-22, Debian-10, Debian-11, Debian-12]
include:
- name: Ubuntu-20
image: "ubuntu:20.04"
suite: focal
GOVER: '1.21'
install: "make ca-certificates git curl"
- name: Ubuntu-22
image: "ubuntu:22.04"
suite: jammy
install: "make ca-certificates git curl golang"
- name: Debian-10
image: "debian:buster"
suite: buster
GOVER: '1.21'
install: "make ca-certificates git curl"
- name: Debian-11
image: "debian:bullseye"
suite: bullseye
GOVER: '1.21'
install: "make ca-certificates git curl"
- name: Debian-12
image: "debian:bookworm"
suite: bookworm
install: "make ca-certificates git curl golang"
container:
image: ${{ matrix.image }}
env:
APT_LISTCHANGES_FRONTEND: none
DEBIAN_FRONTEND: noninteractive
steps:
- name: Install O/S packages
run: |
apt-get update
apt-get install -y --no-install-recommends ${{ matrix.install }}
git config --global --add safe.directory "$GITHUB_WORKSPACE"
echo GOVER: ${{ env.GOVER }}

- name: Checkout repository
uses: actions/checkout@v3
with:
# fetch the whole repot for `git describe` to
# fetch the whole repo for `git describe` to
# work and get the nightly verion
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v4
if: ${{ matrix.GOVER != '' }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.GOVER }}

- name: Make Release
env:
Expand All @@ -115,19 +157,12 @@ jobs:
APTLY_USER: ${{ secrets.APTLY_USER }}
APTLY_PASSWORD: ${{ secrets.APTLY_PASSWORD }}
run: |
./upload-artifacts.sh nightly
./upload-artifacts.sh nightly ${{ matrix.suite }}

- name: Publish release to aptly
if: startsWith(github.event.ref, 'refs/tags')
env:
APTLY_USER: ${{ secrets.APTLY_USER }}
APTLY_PASSWORD: ${{ secrets.APTLY_PASSWORD }}
run: |
./upload-artifacts.sh release

- name: Upload artifacts to GitHub Release
if: startsWith(github.event.ref, 'refs/tags')
uses: softprops/action-gh-release@v1
with:
body: Release ${{ github.ref }} generated by the CI.
files: build/*
./upload-artifacts.sh release ${{ matrix.suite }}
84 changes: 66 additions & 18 deletions upload-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,100 @@ aptly_password="$APTLY_PASSWORD"
aptly_api="https://aptly-ops.aptly.info"
version=`make version`

echo "Publishing version '$version' to $1..."
action=$1
dist=$2

for file in $packages; do
echo "Uploading $file..."
curl -fsS -X POST -F "file=@$file" -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder
usage() {
echo "Usage: $0 nighly jammy|focal|bookworm" >&2
echo " $0 release" >&2
}

if [ -z "$action" ]; then
usage
exit 1
fi

if [ "action" = "nightly" ] && [ -z "$dist" ]; then
usage
exit 1
fi

echo "Publishing version '$version' to $action for $dist...\n"

upload()
{
echo "\nUploading files:"
for file in $packages; do
echo " - $file"
curl -fsS -X POST -F "file=@$file" -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder
done
echo
done
}
cleanup() {
echo "\nCleanup..."
curl -fsS -X DELETE -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder
echo
}
trap cleanup EXIT
Copy link

@szakalboss szakalboss Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanna trap also INT and TERM ? (eg system reboot...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both result in EXIT


if [ "$1" = "nightly" ]; then
if [ "$action" = "nightly" ]; then
if echo "$version" | grep -vq "+"; then
# skip nightly when on release tag
exit 0
fi

aptly_repository=aptly-nightly
aptly_published=s3:repo.aptly.info:./nightly
aptly_repository=aptly-nightly-$dist
aptly_published=s3:repo.aptly.info:nightly-$dist

upload

echo "Adding packages to $aptly_repository..."
echo "\nAdding packages to $aptly_repository ..."
curl -fsS -X POST -u $aptly_user:$aptly_password ${aptly_api}/api/repos/$aptly_repository/file/$folder
echo

echo "Updating published repo..."
echo "\nUpdating published repo $aptly_published ..."
curl -fsS -X PUT -H 'Content-Type: application/json' --data \
'{"AcquireByHash": true, "Signing": {"Batch": true, "Keyring": "aptly.repo/aptly.pub",
"secretKeyring": "aptly.repo/aptly.sec", "PassphraseFile": "aptly.repo/passphrase"}}' \
-u $aptly_user:$aptly_password ${aptly_api}/api/publish/$aptly_published
'{"AcquireByHash": true,
"Signing": {"Batch": true, "Keyring": "aptly.repo/aptly.pub", "secretKeyring": "aptly.repo/aptly.sec", "PassphraseFile": "aptly.repo/passphrase"}}' \
-u $aptly_user:$aptly_password ${aptly_api}/api/publish/$aptly_published/$dist
echo

if [ $dist = "focal" ]; then
echo "\nUpdating legacy nightly repo..."

aptly_repository=aptly-nightly
aptly_published=s3:repo.aptly.info:./nightly

upload

echo "\nAdding packages to $aptly_repository ..."
curl -fsS -X POST -u $aptly_user:$aptly_password ${aptly_api}/api/repos/$aptly_repository/file/$folder
echo

echo "\nUpdating published repo $aptly_published ..."
curl -fsS -X PUT -H 'Content-Type: application/json' --data \
'{"AcquireByHash": true, "Signing": {"Batch": true, "Keyring": "aptly.repo/aptly.pub",
"secretKeyring": "aptly.repo/aptly.sec", "PassphraseFile": "aptly.repo/passphrase"}}' \
-u $aptly_user:$aptly_password ${aptly_api}/api/publish/$aptly_published
echo
fi
fi

if [ "$1" = "release" ]; then
aptly_repository=aptly-release
aptly_snapshot=aptly-$version
aptly_published=s3:repo.aptly.info:./squeeze

echo "Adding packages to $aptly_repository..."
echo "\nAdding packages to $aptly_repository..."
curl -fsS -X POST -u $aptly_user:$aptly_password ${aptly_api}/api/repos/$aptly_repository/file/$folder
echo

echo "Creating snapshot $aptly_snapshot from repo $aptly_repository..."
echo "\nCreating snapshot $aptly_snapshot from repo $aptly_repository..."
curl -fsS -X POST -u $aptly_user:$aptly_password -H 'Content-Type: application/json' --data \
"{\"Name\":\"$aptly_snapshot\"}" ${aptly_api}/api/repos/$aptly_repository/snapshots
echo

echo "Switching published repo to use snapshot $aptly_snapshot..."
echo "\nSwitching published repo $aptly_published to use snapshot $aptly_snapshot..."
curl -fsS -X PUT -H 'Content-Type: application/json' --data \
"{\"AcquireByHash\": true, \"Snapshots\": [{\"Component\": \"main\", \"Name\": \"$aptly_snapshot\"}],
\"Signing\": {\"Batch\": true, \"Keyring\": \"aptly.repo/aptly.pub\",
Expand All @@ -62,5 +112,3 @@ if [ "$1" = "release" ]; then
echo
fi

curl -fsS -X DELETE -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder
echo
Loading