-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate GHA build and package steps
- Loading branch information
Showing
1 changed file
with
92 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
--- | ||
env: | ||
PACKAGE_NAME: promtail | ||
APT_DEPENDENCIES: "libsystemd-dev gccgo-aarch64-linux-gnu gccgo-arm-linux-gnueabi" | ||
PACKAGE_VERSION: v2.9.3 | ||
APT_DEPENDENCIES: "git libsystemd-dev gccgo-aarch64-linux-gnu gccgo-arm-linux-gnueabi" | ||
|
||
name: Build, package and publish | ||
"on": | ||
push: | ||
paths-ignore: | ||
- "*.md" | ||
- LICENSE | ||
- .github/renovate.json | ||
- .gitignore | ||
branches: | ||
- main | ||
pull_request: | ||
|
@@ -15,44 +21,118 @@ name: Build, package and publish | |
jobs: | ||
build: | ||
name: Build & Package | ||
# Check GLIBC versioning on clients if you upgrade this | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- arm | ||
fail-fast: true | ||
container: debian:bookworm-slim | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- name: Install build dependencies | ||
run: apt-get update && apt-get install -y ${APT_DEPENDENCIES} | ||
if: ${{ env.APT_DEPENDENCIES != '' }} | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
with: | ||
repository: grafana/loki.git | ||
ref: ${{ env.PACKAGE_VERSION }} | ||
- name: Set up Golang | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 | ||
with: | ||
go-version: 1.21 | ||
- name: Build | ||
run: | | ||
git config --global --add safe.directory '*' | ||
export GIT_REVISION=$(git rev-parse --short HEAD) | ||
echo $GIT_REVISION | ||
export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
echo $GIT_BRANCH | ||
export IMAGE_TAG=$(./tools/image-tag) | ||
echo $IMAGE_TAG | ||
export GO_LD_FLAGS='-s -w -X ${VPREFIX}.Branch=${GIT_BRANCH} -X ${VPREFIX}.Version=${IMAGE_TAG} -X ${VPREFIX}.Revision=${GIT_REVISION} -X ${VPREFIX}.BuildUser=$(whoami)@$(hostname) -X ${VPREFIX}.BuildDate=$(date -u +"%Y-%m-%dT%H:%M:%SZ")' | ||
GOOS=linux GOARCH=${ARCH} go build -ldflags "${GO_LD_FLAGS}"" -tags netgo -mod vendor --tags=promtail_journal_enabled -o dist/${PACKAGE_NAME}_linux_${ARCH} ./clients/cmd/promtail | ||
ls -laht dist | ||
env: | ||
ARCH: ${{ matrix.goarch }} | ||
VPREFIX: github.com/grafana/loki/pkg/util/build | ||
CGO_ENABLED: 1 | ||
GOARM: 6 | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4 | ||
with: | ||
name: binary-${{ matrix.goarch }} | ||
path: dist/${{ env.PACKAGE_NAME }}_linux_${{ matrix.goarch }} | ||
|
||
build-package: | ||
name: Build Deb Package | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust_arch: | ||
- x86_64-unknown-linux-musl | ||
- arm-unknown-linux-musleabihf | ||
- aarch64-unknown-linux-musl | ||
fail-fast: true | ||
needs: build | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: Make deb package | ||
run: make -j$(nproc) package | ||
- name: Download build artifact | ||
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4 | ||
with: | ||
name: binary-${{ matrix.rust_arch }} | ||
- name: Package | ||
run: | | ||
case ${ARCH} in | ||
x86_64-unknown-linux-musl) | ||
export DEB_ARCH=amd64;; | ||
arm-unknown-linux-musleabihf) | ||
export DEB_ARCH=armhf;; | ||
aarch64-unknown-linux-musl) | ||
export DEB_ARCH=aarch64;; | ||
esac | ||
chmod +x ${ARCH}/release/starship | ||
bundle exec fpm -f \ | ||
-s dir \ | ||
-t deb \ | ||
--deb-priority optional \ | ||
--maintainer [email protected] \ | ||
--vendor https://starship.rs \ | ||
--license ISC \ | ||
-n $DEB_NAME \ | ||
--description "${APP_DESCRIPTION}" \ | ||
--url ${APP_URL} \ | ||
--prefix / \ | ||
-a ${DEB_ARCH} \ | ||
-v ${PACKAGE_VERSION}-$(printf "%04d" $GITHUB_RUN_NUMBER) \ | ||
${ARCH}/release/starship=/usr/bin/starship | ||
env: | ||
BUILD_NUMBER: ${{ github.run_number }} | ||
- name: Upload deb file | ||
DEB_NAME: ${{ env.PACKAGE_NAME }} | ||
APP_DESCRIPTION: ${{ env.PACKAGE_DESCRIPTION }} | ||
APP_URL: https://starship.rs | ||
ARCH: ${{ matrix.rust_arch }} | ||
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4 | ||
with: | ||
name: deb | ||
name: deb-package-${{ matrix.rust_arch }} | ||
path: "*.deb" | ||
publish: | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
if: github.event_name != 'pull_request' | ||
needs: build | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- name: Download deb artifact | ||
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4 | ||
with: | ||
name: deb | ||
name: deb-package-* | ||
- name: Upload to Apt repo | ||
env: | ||
APT_CREDENTIALS: ${{ secrets.APT_CREDENTIALS }} | ||
|