From 9a32f3838166cc6fa276dc88253a836ea1068b1e Mon Sep 17 00:00:00 2001 From: Gabor Kozma Date: Tue, 23 Apr 2024 09:42:20 +0200 Subject: [PATCH] new workflows for axosyslog rpm build --- .../workflows/syslog-ng-create-packages.yml | 75 +++++++++++++++++ .github/workflows/syslog-ng-packages.yml | 84 +++++++++++++++++++ .github/workflows/syslog-ng-stable.yml | 24 ++++++ 3 files changed, 183 insertions(+) create mode 100644 .github/workflows/syslog-ng-create-packages.yml create mode 100644 .github/workflows/syslog-ng-packages.yml diff --git a/.github/workflows/syslog-ng-create-packages.yml b/.github/workflows/syslog-ng-create-packages.yml new file mode 100644 index 0000000000..ab31856df7 --- /dev/null +++ b/.github/workflows/syslog-ng-create-packages.yml @@ -0,0 +1,75 @@ +name: Create package from source tarball + +on: + workflow_call: + inputs: + source-tarball-artifact-name: + required: true + type: string + dbld-image-mode: + required: true + type: string # cache / build + distros: + required: false + type: string + default: | + [ + "almalinux-8", + ] + +jobs: + create-packages: + name: ${{ matrix.distro }} + + runs-on: ubuntu-latest + + strategy: + matrix: + distro: ${{ fromJson(inputs.distros) }} + fail-fast: false + + steps: + - name: Download source tarball artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.source-tarball-artifact-name }} + + - name: Extract source tarball + run: | + mkdir syslog-ng + tar --strip-components=1 -xvf syslog-ng*.tar.gz -C syslog-ng + + - name: Prepare docker image + working-directory: syslog-ng + run: | + if [[ "${{ inputs.dbld-image-mode }}" = "build" ]] + then + ./dbld/rules image-${{ matrix.distro }} + elif [[ "${{ inputs.dbld-image-mode }}" = "cache" ]] + then + ./dbld/rules cache-image-${{ matrix.distro }} + else + echo Unexpected input: dbld-image-mode=${{ inputs.dbld-image-mode }} + false + fi + + - name: Create package + working-directory: syslog-ng + run: | + ./dbld/rules package-${{ matrix.distro }} + + - name: Prepare package for artifact + # We want to keep the directory structure starting with ${{ matrix.distro }}, + # but it can only be done, if we give its parent directory as `path` to upload-artifact. + # There are other directories in dbld/build which we do not want to upload, + # so let's make a temporary directory and move the ${{ matrix.distro }} directory there. + run: | + mkdir package + cp -r syslog-ng/dbld/build/${{ matrix.distro }} package/ + + - name: Store package as artifact + uses: actions/upload-artifact@v3 + with: + name: package-${{ matrix.distro }} + path: package/* + if-no-files-found: error diff --git a/.github/workflows/syslog-ng-packages.yml b/.github/workflows/syslog-ng-packages.yml new file mode 100644 index 0000000000..2998c99b42 --- /dev/null +++ b/.github/workflows/syslog-ng-packages.yml @@ -0,0 +1,84 @@ +name: Packages +on: + workflow_call: + inputs: + repo: + description: 'syslog-ng repository' + required: true + default: 'syslog-ng/syslog-ng' + type: string + version: + description: 'syslog-ng version' + required: true + type: string + + workflow_dispatch: + inputs: + repo: + description: 'syslog-ng repository' + required: true + default: 'syslog-ng/syslog-ng' + type: string + version: + description: 'syslog-ng version' + required: true + type: string + +jobs: + create-source-tarball: + runs-on: ubuntu-latest + steps: + - name: Get syslog-ng tarball + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release download --repo '${{ inputs.repo }}' -p 'syslog-ng-${{ inputs.version }}.tar.gz' 'syslog-ng-${{ inputs.version }}' + + - name: Extract source tarball + run: | + mkdir syslog-ng + tar --strip-components=1 -xvf syslog-ng*.tar.gz -C syslog-ng + rm syslog-ng*.tar.gz + + - name: AxoSyslog patches + working-directory: syslog-ng + run: | + sed -i 's/Name: syslog-ng/Name: axosyslog/' packaging/rhel/syslog-ng.spec + sed -i 's|%{name}-%{version}.tar.gz|syslog-ng-%{version}.tar.gz|' packaging/rhel/syslog-ng.spec + sed -i 's|URL.*|URL: https://axoflow.com/docs/axosyslog-core/|' packaging/rhel/syslog-ng.spec + sed -i 's|Provides: syslog|&\n\nConflicts: syslog-ng\nConflicts: syslog-ng-premium-edition|' packaging/rhel/syslog-ng.spec + sed -i 's|%setup -q|%setup -q -n syslog-ng-%{version}|' packaging/rhel/syslog-ng.spec + sed -i 's|/%{name}|/syslog-ng|g' packaging/rhel/syslog-ng.spec + sed -i 's|/lib%{name}|/libsyslog-ng|g' packaging/rhel/syslog-ng.spec + sed -i 's|^.*czanik/syslog-ng-githead.*$||' dbld/builddeps + + # Remove extra dependencies + sed -i 's|almalinux.*|&,nocriterion,noriemann,nokafka,nomqtt,nojava|' dbld/build.manifest + + cat packaging/rhel/syslog-ng.spec + + - name: Prepare docker image + working-directory: syslog-ng + run: ./dbld/rules cache-image-tarball + + - name: Create source tarball + working-directory: syslog-ng + run: ./dbld/rules pkg-tarball + + - name: Store source tarball as artifact + uses: actions/upload-artifact@v4 + with: + name: source-tarball + path: syslog-ng/dbld/build/*.tar.* + if-no-files-found: error + + create-packages: + needs: create-source-tarball + uses: ./.github/workflows/syslog-ng-create-packages.yml + with: + source-tarball-artifact-name: source-tarball + dbld-image-mode: cache + distros: | + [ + "almalinux-8" + ] diff --git a/.github/workflows/syslog-ng-stable.yml b/.github/workflows/syslog-ng-stable.yml index c1e58375cf..5fd358a268 100644 --- a/.github/workflows/syslog-ng-stable.yml +++ b/.github/workflows/syslog-ng-stable.yml @@ -7,6 +7,30 @@ on: - 'syslog-ng-*' jobs: + prepare: + name: Prepare Workflow + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Regex matching + uses: kaisugi/action-regex-match@v1.0.0 + id: unpack_tag + with: + text: ${{ github.ref }} + regex: 'refs/tags/syslog-ng-(.*)' + outputs: + version: ${{ steps.unpack_tag.outputs.group1 }} + + publish-packages: + uses: ./.github/workflows/syslog-ng-packages.yml + needs: + - prepare + with: + repo: syslog-ng/syslog-ng + version: ${{ needs.prepare.outputs.version }} + publish-image: uses: ./.github/workflows/syslog-ng-docker.yml with: