mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
improve CI workflow
- use debian version consistently - if the commit is not on a git tag, append ci version - avoid double zipping - cleanup binary builds - replace `make release` with `make binaries` - add missing files to archives - use matrix build for deb packages - allow building release version - keep directory inside zip archives - accept releases only on master only tags on master will trigger a release - cleanup namings - keep path in zip - add retention period for pipeline artifacts
This commit is contained in:
+33
-18
@@ -94,13 +94,14 @@ jobs:
|
||||
files: coverage.txt
|
||||
|
||||
ci-debian-build:
|
||||
name: "CI Build"
|
||||
name: "Build"
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
name: ["Debian 13/testing", "Debian 12/bookworm", "Debian 11/bullseye", "Debian 10/buster", "Ubuntu 24.04", "Ubuntu 22.04", "Ubuntu 20.04"]
|
||||
arch: ["amd64", "i386" , "arm64" , "armhf"]
|
||||
include:
|
||||
- name: "Debian 13/testing"
|
||||
suite: trixie
|
||||
@@ -151,16 +152,29 @@ jobs:
|
||||
with:
|
||||
go-version: ${{ steps.goversion.outputs.GOVER }}
|
||||
|
||||
- name: Check is CI or Release
|
||||
run: |
|
||||
if [ -z "`git tag --points-at HEAD`" ]; then
|
||||
releasetype=ci
|
||||
else
|
||||
releasetype=release
|
||||
fi
|
||||
echo RELEASETYPE=$releasetype >> $GITHUB_OUTPUT
|
||||
id: releasetype
|
||||
|
||||
- name: "Build Debian packages"
|
||||
env:
|
||||
GOBIN: /usr/local/bin
|
||||
run: |
|
||||
GOPATH=$PWD/.go go generate -v
|
||||
DEBEMAIL="CI <runner@github>" dch -v `make version` "CI build"
|
||||
dpkg-buildpackage -us -uc -b -d --host-arch=amd64
|
||||
dpkg-buildpackage -us -uc -b -d --host-arch=i386
|
||||
dpkg-buildpackage -us -uc -b -d --host-arch=arm64
|
||||
dpkg-buildpackage -us -uc -b -d --host-arch=armhf
|
||||
if [ "${{ steps.releasetype.outputs.RELEASETYPE }}" = "ci" ]; then
|
||||
DEBEMAIL="CI <runner@github>" dch -v `make version` "CI build"
|
||||
fi
|
||||
buildtype="any"
|
||||
if [ "${{ matrix.arch }}" = "amd64" ]; then # build 'all' type package only on amd64
|
||||
buildtype="any,all"
|
||||
fi
|
||||
dpkg-buildpackage -us -uc --build=$buildtype -d --host-arch=${{ matrix.arch }}
|
||||
mkdir -p build && mv ../*.deb build/
|
||||
cd build && ls -l *.deb
|
||||
|
||||
@@ -173,15 +187,15 @@ jobs:
|
||||
./upload-artifacts.sh ci ${{ matrix.suite }}
|
||||
|
||||
- name: "Publish release to aptly"
|
||||
if: startsWith(github.event.ref, 'refs/tags')
|
||||
if: steps.releasetype.outputs.RELEASETYPE == 'release' && github.ref == 'refs/heads/master'
|
||||
env:
|
||||
APTLY_USER: ${{ secrets.APTLY_USER }}
|
||||
APTLY_PASSWORD: ${{ secrets.APTLY_PASSWORD }}
|
||||
run: |
|
||||
./upload-artifacts.sh release ${{ matrix.suite }}
|
||||
|
||||
ci-release-build:
|
||||
name: "CI Build (Binary)"
|
||||
ci-binary-build:
|
||||
name: "Build"
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
@@ -207,8 +221,7 @@ jobs:
|
||||
|
||||
- name: "Get aptly version"
|
||||
run: |
|
||||
# Because dpkg-parsechangelog is not installed, will return the latest git tag
|
||||
echo "VERSION=$(make version RELEASE=yes)" >> $GITHUB_OUTPUT
|
||||
echo "VERSION=$(make version)" >> $GITHUB_OUTPUT
|
||||
id: releaseversion
|
||||
|
||||
- name: "Setup Go"
|
||||
@@ -216,23 +229,25 @@ jobs:
|
||||
with:
|
||||
go-version: ${{ steps.goversion.outputs.GOVER }}
|
||||
|
||||
- name: "Build packages for ${{ matrix.goos }} ${{ matrix.goarch }}"
|
||||
- name: "Build aptly ${{ matrix.goos }}/${{ matrix.goarch }}"
|
||||
env:
|
||||
GOBIN: /usr/local/bin
|
||||
run: |
|
||||
echo ${{ steps.releaseversion.outputs.VERSION }} > VERSION
|
||||
make release GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }}
|
||||
make binaries GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }}
|
||||
cd build; unzip aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
|
||||
rm -f aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
|
||||
path: build/aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
|
||||
name: aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
|
||||
path: build/*
|
||||
retention-days: 90
|
||||
|
||||
gh-release:
|
||||
name: "Github Release: ${{ github.ref_name }}"
|
||||
name: "Github Release"
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: false
|
||||
needs: ci-release-build
|
||||
needs: ci-binary-build
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- name: Download Artifacts
|
||||
|
||||
@@ -90,15 +90,14 @@ man: ## Create man pages
|
||||
make -C man
|
||||
|
||||
version: ## Print aptly version
|
||||
@ts=`TZ=UTC git show -s --format='%cd.%h' --date=format-local:'%Y%m%d%H%M%S'`; \
|
||||
@ci="" ; \
|
||||
if [ -z "`git tag --points-at HEAD`" ]; then \
|
||||
ci=`TZ=UTC git show -s --format='+%cd.%h' --date=format-local:'%Y%m%d%H%M%S'`; \
|
||||
fi ; \
|
||||
if which dpkg-parsechangelog > /dev/null 2>&1; then \
|
||||
if [ -z "$$ts" ]; then \
|
||||
dpkg-parsechangelog -S Version; \
|
||||
else \
|
||||
echo `dpkg-parsechangelog -S Version`+$$ts; \
|
||||
fi \
|
||||
echo `dpkg-parsechangelog -S Version`$$ci; \
|
||||
else \
|
||||
git describe --tags --always | sed 's@^v@@' | sed 's@-@+@g'; \
|
||||
echo `grep ^aptly -m1 debian/changelog | sed 's/.*(\([^)]\+\)).*/\1/'`$$ci ; \
|
||||
fi
|
||||
|
||||
build: ## Build aptly
|
||||
@@ -106,12 +105,14 @@ build: ## Build aptly
|
||||
go generate
|
||||
go build -o build/aptly
|
||||
|
||||
release: version ## build release archive in build/ for GOOS and GOARCH
|
||||
binaries: ## Build binary releases (FreeBSD, MacOS, Linux tar)
|
||||
@mkdir -p build/tmp/man build/tmp/completion/bash_completion.d build/tmp/completion/zsh/vendor-completions
|
||||
@make version > VERSION
|
||||
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o build/tmp/aptly -ldflags='-extldflags=-static'
|
||||
@cp man/aptly.1 build/tmp/man/
|
||||
@cp completion.d/aptly build/tmp/completion/bash_completion.d/
|
||||
@cp completion.d/_aptly build/tmp/completion/zsh/vendor-completions/
|
||||
@cp README.rst LICENSE AUTHORS build/tmp/
|
||||
@gzip -f build/tmp/man/aptly.1
|
||||
@path="aptly_$(VERSION)_$(GOOS)_$(GOARCH)"; \
|
||||
rm -rf "build/$$path"; \
|
||||
@@ -143,8 +144,8 @@ docker-system-tests: ## Run system tests in docker container (add TEST=t04_mirr
|
||||
docker-lint: ## Run golangci-lint in docker container
|
||||
@docker run -it --rm -v ${PWD}:/app -e GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) aptly-dev /app/system/run-golangci-lint
|
||||
|
||||
docker-release:
|
||||
@docker run -it --rm -v ${PWD}:/app aptly-dev /app/system/run-release
|
||||
docker-binaries: ## Build binary releases (FreeBSD, MacOS, Linux tar) in docker container
|
||||
@docker run -it --rm -v ${PWD}:/app aptly-dev /app/system/build-binaries
|
||||
|
||||
flake8: ## run flake8 on system tests
|
||||
flake8 system
|
||||
@@ -153,4 +154,4 @@ clean: ## remove local build and module cache
|
||||
test -d .go/ && chmod u+w -R .go/ && rm -rf .go/ || true
|
||||
rm -rf build/ docs/ obj-*-linux-gnu*
|
||||
|
||||
.PHONY: help man prepare version release docker-build-aptly-dev docker-system-tests docker-unit-tests docker-lint docker-build build docker-aptly clean
|
||||
.PHONY: help man prepare version binaries docker-release docker-system-tests docker-unit-tests docker-lint docker-build docker-image build docker-aptly clean
|
||||
|
||||
@@ -6,4 +6,4 @@ rm -rf /app/build/tmp
|
||||
usermod -u `stat -c %u /app` aptly >/dev/null
|
||||
chown -R `stat -c %u /app` /var/lib/aptly
|
||||
|
||||
su - aptly -c "cd /app; export GOPATH=/app/.go; make release"
|
||||
su - aptly -c "cd /app; export GOPATH=/app/.go; make binaries"
|
||||
Reference in New Issue
Block a user