From 432db40dc4f20ef3f84ee61183254062ed3f34dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Sun, 19 May 2024 00:51:59 +0200 Subject: [PATCH] ci: add workflow for creating snapshot container images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- .github/workflows/axosyslog-docker.yml | 22 ++++++-- .../workflows/axosyslog-image-snapshot.yml | 52 +++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/axosyslog-image-snapshot.yml diff --git a/.github/workflows/axosyslog-docker.yml b/.github/workflows/axosyslog-docker.yml index 76ceaa5fea..ce7460f8c3 100644 --- a/.github/workflows/axosyslog-docker.yml +++ b/.github/workflows/axosyslog-docker.yml @@ -6,6 +6,10 @@ on: type: required: true type: string # stable / snapshot + platforms: + required: false + type: string + default: linux/amd64,linux/arm64,linux/arm/v7 snapshot-tarball-artifact: required: false type: string @@ -21,17 +25,27 @@ env: DEBUG_PLATFORM: linux/amd64 jobs: + prepare: + runs-on: ubuntu-latest + outputs: + platform-matrix: ${{ steps.platforms.outputs.platform-matrix }} + steps: + - id: platforms + env: + PLATFORMS: ${{ inputs.platforms }} + run: | + PLATFORM_MATRIX="$(echo "$PLATFORMS" | jq 'split(",")' -Rc)" + echo "platform-matrix=$PLATFORM_MATRIX" >> $GITHUB_OUTPUT + image-build: if: github.repository_owner == 'axoflow' runs-on: ubuntu-latest + needs: prepare strategy: fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm64 - - linux/arm/v7 + platform: ${{ fromJSON(needs.prepare.outputs.platform-matrix) }} steps: - name: Prepare diff --git a/.github/workflows/axosyslog-image-snapshot.yml b/.github/workflows/axosyslog-image-snapshot.yml new file mode 100644 index 0000000000..f39c9cc6f1 --- /dev/null +++ b/.github/workflows/axosyslog-image-snapshot.yml @@ -0,0 +1,52 @@ +name: AxoSyslog Docker snapshot image + +on: + workflow_dispatch: + inputs: + platforms: + default: "linux/amd64,linux/arm64,linux/arm/v7" + push: + branches: + - main + +jobs: + tarball: + runs-on: ubuntu-latest + outputs: + snapshot-version: ${{ steps.snapshot-version.outputs.SNAPSHOT_VERSION }} + steps: + - name: Checkout AxoSyslog source + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Prepare docker image + run: ./dbld/rules cache-image-tarball + + - 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/axosyslog-}" + 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@v4 + with: + name: source-tarball + path: dbld/build/*.tar.* + + publish-image: + uses: ./.github/workflows/axosyslog-docker.yml + needs: tarball + with: + type: snapshot + platforms: ${{ inputs.platforms || 'linux/amd64' }} + snapshot-tarball-artifact: source-tarball + snapshot-version: ${{ needs.tarball.outputs.snapshot-version }} + snapshot-tags: dev-${{ github.ref_name }}