Skip to content

Commit

Permalink
Merge pull request #3 from axoflow/nightly-version-tag
Browse files Browse the repository at this point in the history
ci/docker: publish version tags for nightly
  • Loading branch information
alltilla authored Feb 21, 2023
2 parents eeba57c + 496b36d commit 6a6020b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
tarball-artifact:
required: false
type: string
snapshot-version:
required: false
type: string

env:
DOCKER_IMAGE_NAME: ghcr.io/axoflow/syslog-ng
Expand Down Expand Up @@ -57,7 +60,7 @@ jobs:
if [[ '${{ inputs.pkg-type }}' = 'stable' ]]; then
TAGS='${{ steps.stable-tags.outputs.tags }}'
elif [[ '${{ inputs.pkg-type }}' = 'nightly' ]]; then
TAGS="${DOCKER_IMAGE_NAME}:nightly"
TAGS="${DOCKER_IMAGE_NAME}:nightly,${DOCKER_IMAGE_NAME}:${{ inputs.snapshot-version }}"
else
echo Unexpected input: pkg-type=${{ inputs.pkg-type }}
false
Expand All @@ -72,4 +75,6 @@ jobs:
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.tags.outputs.TAGS }}
build-args: PKG_TYPE=${{ inputs.pkg-type }}
build-args: |
PKG_TYPE=${{ inputs.pkg-type }}
SNAPSHOT_VERSION=${{ inputs.snapshot-version }}
24 changes: 20 additions & 4 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ on:
- cron: '00 23 * * *'

jobs:
create-source-tarball:
tarball:
name: create-source-tarball
runs-on: ubuntu-latest
outputs:
snapshot-version: ${{ steps.snapshot-version.outputs.SNAPSHOT_VERSION }}
steps:
- name: Checkout syslog-ng source
uses: actions/checkout@v3
Expand All @@ -35,6 +38,15 @@ jobs:
- name: Create source tarball
run: ./dbld/rules pkg-tarball

- name: Determine snapshot version
id: snapshot-version
run: |
tarball_filename="$(find dbld/build -name '*.tar.*' -printf '%f\n')"
tarball_name="${tarball_filename/\.tar.*}"
tarball_version="${tarball_name/syslog-ng-}"
pkg_version="$(echo $tarball_version | sed -E 's|(([0-9]+\.){2}[0-9]+).*|\1|')_git$(date +%Y%m%d)"
echo "SNAPSHOT_VERSION=${pkg_version}" >> $GITHUB_OUTPUT
- name: Store source tarball as artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -43,7 +55,7 @@ jobs:

build-and-test:
runs-on: ubuntu-latest
needs: create-source-tarball
needs: tarball
steps:
- name: Checkout source
uses: actions/checkout@v3
Expand All @@ -61,7 +73,10 @@ jobs:
file: alpine.dockerfile
load: true
tags: syslog-ng:test
build-args: PKG_TYPE=nightly
build-args: |
PKG_TYPE=nightly
SNAPSHOT_VERSION=${{ needs.tarball.outputs.snapshot-version }}
- name: Smoke test
run: |
Expand All @@ -76,7 +91,8 @@ jobs:
publish-image:
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/docker.yml
needs: build-and-test
needs: [tarball, build-and-test]
with:
pkg-type: nightly
tarball-artifact: source-tarball
snapshot-version: ${{ needs.tarball.outputs.snapshot-version }}
5 changes: 2 additions & 3 deletions alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine:3.17 as apkbuilder

ARG PKG_TYPE=stable
ARG SNAPSHOT_VERSION

RUN apk add --update-cache \
alpine-conf \
Expand All @@ -21,9 +22,7 @@ RUN mkdir packages \
tarball_filename="$(ls *.tar.*)"; \
[ -z "$tarball_filename" ] && echo "Tarball for nightly can not be found" && exit 1; \
tarball_name="${tarball_filename/\.tar.*}"; \
tarball_version="${tarball_name/syslog-ng-}"; \
pkg_version="$(echo $tarball_version | sed -E 's|(([0-9]+\.){2}[0-9]+).*|\1|')_git$(date +%Y%m%d)"; \
sed -i -e "s|^pkgver=.*|pkgver=$pkg_version|" -e "s|^builddir=.*|builddir=\"\$srcdir/$tarball_name\"|" APKBUILD; \
sed -i -e "s|^pkgver=.*|pkgver=$SNAPSHOT_VERSION|" -e "s|^builddir=.*|builddir=\"\$srcdir/$tarball_name\"|" APKBUILD; \
sed -i -e "s|^source=.*|source=\"$tarball_filename\"|" APKBUILD; \
fi \
&& abuild checksum \
Expand Down

0 comments on commit 6a6020b

Please sign in to comment.