move release script to Makefile

This commit is contained in:
iofq
2024-09-19 00:05:47 -05:00
committed by André Roth
parent 5e86a0b9e6
commit 056df39a3c
4 changed files with 43 additions and 16 deletions

View File

@@ -205,6 +205,12 @@ jobs:
echo "GOVER=$(sed -n 's/^go \(.*\)/\1/p' go.mod)" >> $GITHUB_OUTPUT
id: goversion
- 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
id: releaseversion
- name: "Setup Go"
uses: actions/setup-go@v3
with:
@@ -214,23 +220,13 @@ jobs:
env:
GOBIN: /usr/local/bin
run: |
mkdir -p tmp/man tmp/completion/bash_completion.d tmp/completion/zsh/vendor-completions
go version
echo ${{ github.ref_name }} > VERSION
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o tmp/aptly -ldflags='-extldflags=-static'
cp man/aptly.1 tmp/man/
cp completion.d/aptly tmp/completion/bash_completion.d/
cp completion.d/_aptly tmp/completion/zsh/vendor-completions/
gzip tmp/man/aptly.1
path="aptly_${{ matrix.goos }}_${{ matrix.goarch }}"
mkdir -p $path
mv tmp "$path"
zip -r "$path" . -i "$path/*"
echo ${{ steps.releaseversion.outputs.VERSION }} > VERSION
make release GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }}
- uses: actions/upload-artifact@v4
with:
name: aptly_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: aptly_${{ matrix.goos }}_${{ matrix.goarch }}.zip
name: aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: build/aptly_${{ steps.releaseversion.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
gh-release:
name: "Github Release: ${{ github.ref_name }}"

View File

@@ -1,11 +1,14 @@
GOPATH=$(shell go env GOPATH)
VERSION=$(shell make version)
VERSION=$(shell make -s version)
PYTHON?=python3
TESTS?=
BINPATH?=$(GOPATH)/bin
RUN_LONG_TESTS?=yes
GOLANGCI_LINT_VERSION=v1.54.1 # version supporting go 1.19
COVERAGE_DIR?=$(shell mktemp -d)
GOOS=$(shell go env GOHOSTOS)
GOARCH=$(shell go env GOHOSTARCH)
RELEASE=no
# Uncomment to update test outputs
# CAPTURE := "--capture"
@@ -103,6 +106,22 @@ build: ## Build aptly
go generate
go build -o build/aptly
release: version ## build release archive in build/ for GOOS and GOARCH
@mkdir -p build/tmp/man build/tmp/completion/bash_completion.d build/tmp/completion/zsh/vendor-completions
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/
@gzip -f build/tmp/man/aptly.1
@path="aptly_$(VERSION)_$(GOOS)_$(GOARCH)"; \
rm -rf "build/$$path"; \
mv build/tmp build/"$$path"; \
rm -rf build/tmp; \
cd build; \
zip -r "$$path".zip "$$path" > /dev/null \
&& echo "Built build/$${path}.zip"; \
rm -rf "$$path"
docker-image: ## Build aptly-dev docker image
@docker build -f system/Dockerfile . -t aptly-dev
@@ -124,6 +143,9 @@ 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
flake8: ## run flake8 on system tests
flake8 system

View File

@@ -4,7 +4,7 @@ RUN echo deb http://deb.debian.org/debian bookworm-backports main > /etc/apt/sou
RUN apt-get update -y && apt-get install -y --no-install-recommends curl gnupg apg bzip2 xz-utils ca-certificates \
golang/bookworm-backports golang-go/bookworm-backports golang-doc/bookworm-backports golang-src/bookworm-backports \
make git python3 python3-requests-unixsocket python3-termcolor python3-swiftclient python3-boto python3-azure-storage g++ python3-etcd3 python3-plyvel graphviz devscripts sudo dh-golang binutils-i686-linux-gnu binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf bash-completion && \
make git python3 python3-requests-unixsocket python3-termcolor python3-swiftclient python3-boto python3-azure-storage g++ python3-etcd3 python3-plyvel graphviz devscripts sudo dh-golang binutils-i686-linux-gnu binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf bash-completion zip && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN useradd -m --shell /bin/sh --home-dir /var/lib/aptly aptly

9
system/run-release Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
# cleanup
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"