diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c7eddb54..536ce3b8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,24 +48,33 @@ jobs: - run: make build-sh-ui - uses: actions/upload-artifact@v4 with: - name: statshouse-${{needs.env.outputs.version}}-ui + name: statshouse-ui-${{needs.env.outputs.version}} path: | - statshouse-ui/build + cmd/statshouse-api/build .dummy_preserves_directory_structure outputs: - artifact: statshouse-${{needs.env.outputs.version}}-ui - almalinux: + artifact: statshouse-ui-${{needs.env.outputs.version}} + rpm: + strategy: + matrix: + image: ["centos:centos7", "almalinux:9"] needs: [env, frontend] - uses: ./.github/workflows/build_rpm.yml - with: - ref: ${{needs.env.outputs.ref}} - ref_timestamp: ${{needs.env.outputs.ref_timestamp}} - timestamp: ${{needs.env.outputs.timestamp}} - version: ${{needs.env.outputs.version}} - name: almalinux - release: 9.2 - frontend-artifact: ${{needs.frontend.outputs.artifact}} - secrets: inherit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: VKCOM/statshouse + ref: ${{needs.env.outputs.ref}} + fetch-depth: 0 + - uses: actions/download-artifact@v4 + with: + name: ${{needs.frontend.outputs.artifact}} + - run: echo "BUILD_VERSION=`echo ${{needs.env.outputs.version}} | sed -e 's:-:.:g'`" >> $GITHUB_ENV + - run: build/makerpm.sh ${{matrix.image}} + - uses: actions/upload-artifact@v4 + with: + name: statshouse-pkg-rpm-${{needs.env.outputs.version}}${{strategy.job-index}} + path: RPMS/*.rpm debian: if: ${{false}} strategy: @@ -114,7 +123,7 @@ jobs: secrets: inherit draft_release: if: ${{ github.event.inputs.draft_release }} - needs: [env, ubuntu_focal, almalinux] + needs: [env, rpm, ubuntu_focal] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -124,17 +133,8 @@ jobs: fetch-depth: 0 - uses: actions/download-artifact@v4 with: - name: ${{needs.almalinux.outputs.artifact}} - path: pkg/rpm - - uses: actions/download-artifact@v4 - if: ${{false}} - with: - name: ${{needs.debian.outputs.artifact}} - path: pkg/deb - - uses: actions/download-artifact@v4 - with: - name: ${{needs.ubuntu_focal.outputs.artifact}} - path: pkg/deb + pattern: statshouse-pkg-* + path: pkg/ - run: gh release create --draft --generate-notes --title "${{github.event.inputs.tag}}" ${{github.event.inputs.tag}} $(find ./pkg -type f -name *.deb -o -name *.rpm) env: GITHUB_TOKEN: ${{secrets.DEVTOOLS_GITHUB_TOKEN}} diff --git a/.github/workflows/build_deb.yml b/.github/workflows/build_deb.yml index fed830492..1a3b7f744 100644 --- a/.github/workflows/build_deb.yml +++ b/.github/workflows/build_deb.yml @@ -34,9 +34,6 @@ on: frontend-artifact: type: string required: true - outputs: - artifact: - value: statshouse-${{inputs.version}}-deb jobs: binaries: uses: ./.github/workflows/build_binaries.yml @@ -83,8 +80,8 @@ jobs: debuild --no-lintian -us -uc -b - uses: actions/upload-artifact@v4 with: - name: statshouse-${{inputs.version}}-deb + name: statshouse-pkg-deb-${{inputs.version}}${{github.run_number}}${{strategy.job-index}} path: | ./statshouse_*.deb - # ./statshouse-api_*.deb - # ./statshouse-metadata_*.deb + ./statshouse-api_*.deb + ./statshouse-metadata_*.deb diff --git a/.github/workflows/build_rpm.yml b/.github/workflows/build_rpm.yml deleted file mode 100644 index 5b2a8f9b5..000000000 --- a/.github/workflows/build_rpm.yml +++ /dev/null @@ -1,69 +0,0 @@ -on: - workflow_call: - inputs: - ref: - type: string - required: true - ref_timestamp: - type: string - required: true - timestamp: - type: string - required: true - version: - type: string - required: true - name: - type: string - required: true - release: - type: string - required: true - frontend-artifact: - type: string - required: true - outputs: - artifact: - value: statshouse-${{inputs.version}}-rpm -jobs: - binaries: - uses: ./.github/workflows/build_binaries.yml - with: - container_json: '{"image":"${{inputs.name}}:${{inputs.release}}"}' - ref: ${{inputs.ref}} - ref_timestamp: ${{inputs.ref_timestamp}} - timestamp: ${{inputs.timestamp}} - version: ${{inputs.version}} - name: ${{inputs.name}} - release: ${{inputs.release}} - run: 'dnf group install -y "Development Tools"' - setup-go: true - package: - needs: [binaries] - runs-on: ubuntu-latest - container: - image: ${{inputs.name}}:${{inputs.release}} - steps: - - run: dnf group install -y "Development Tools" - - uses: actions/checkout@v4 - with: - repository: VKCOM/statshouse - ref: ${{inputs.ref}} - fetch-depth: 0 - - uses: actions/download-artifact@v4 - with: - name: ${{needs.binaries.outputs.artifact}} - path: target - - uses: actions/download-artifact@v4 - with: - name: ${{inputs.frontend-artifact}} - - run: echo "BUILD_VERSION=`echo ${{inputs.version}} | sed -e 's:-:.:g'`" >> $GITHUB_ENV - - run: | - chmod +x target/* - mkdir -p BUILD BUILDROOT SOURCES SPECS SRPMS RPMS - cp build/statshouse.spec SPECS/ - rpmbuild --define "_topdir `pwd`" --define "BUILD_VERSION $BUILD_VERSION" --define "OS_NAME_RELEASE ${{inputs.name}}${{inputs.release}}" -bb SPECS/statshouse.spec - - uses: actions/upload-artifact@v4 - with: - name: statshouse-${{inputs.version}}-rpm - path: RPMS/statshouse-${{env.BUILD_VERSION}}*.rpm diff --git a/build/debian/statshouse-api.install b/build/debian/statshouse-api.install index aeb9c73d8..abcbfcb45 100644 --- a/build/debian/statshouse-api.install +++ b/build/debian/statshouse-api.install @@ -1,3 +1,3 @@ ../target/statshouse-api usr/bin/ ../cmd/statshouse-api/statshouse-api.service usr/lib/systemd/system/ -../statshouse-ui/build usr/lib/statshouse-api/statshouse-ui/ +../cmd/statshouse-api/build usr/lib/statshouse-api/statshouse-ui/ diff --git a/build/makerpm.sh b/build/makerpm.sh new file mode 100755 index 000000000..903c9f68a --- /dev/null +++ b/build/makerpm.sh @@ -0,0 +1,86 @@ +#!/bin/bash +set -e + +while (( "$#" )); do + +IMAGE=$1 +IMAGE_NAME=${IMAGE%:*} +IMAGE_TAG=${IMAGE#*:} + +case "$IMAGE_NAME" in + "almalinux") NAME_RELEASE="almalinux$IMAGE_TAG"; DNF=dnf ;; + "centos") NAME_RELEASE=$IMAGE_TAG; DNF=yum ;; + *) echo "Target name \"$IMAGE_NAME\" is not recognized!"; shift; continue ;; +esac + +NAME_RELEASE=$(echo $NAME_RELEASE | sed -e 's/-/./g;s/:/./g') + +if [[ -z $GOLANG_VERSION ]]; then + echo 'Go version is not specified, using 1.22' + GOLANG_VERSION='1.22.0' +fi + +# version +UPSTREAM=$(git describe --tags --always --dirty) +UPSTREAM=${UPSTREAM#v} # v1.0.0 -> 1.0.0 +BUILD_TIME=$(date +%FT%T%z) +REACT_APP_BUILD_VERSION=$UPSTREAM-$BUILD_TIME +if [[ -z $BUILD_VERSION ]]; then + if [[ ! -z $BUILD_VERSION_SUFFIX ]]; then + BUILD_VERSION=$UPSTREAM-$BUILD_VERSION_SUFFIX + elif [[ ! -z $TAG ]]; then + BUILD_VERSION=$UPSTREAM-$TAG + else + BUILD_VERSION=$UPSTREAM + fi +fi + +if [[ -z $GID ]]; then + GID=$(id -g) +fi + +# builder image +BUILD_IMAGE=statshouse_builder_$NAME_RELEASE +docker image build -t $BUILD_IMAGE - <