Skip to content

Commit

Permalink
RPM package
Browse files Browse the repository at this point in the history
  • Loading branch information
alpinskiy committed Nov 3, 2023
1 parent 09f8d62 commit 6ee4e78
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 64 deletions.
85 changes: 50 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
echo "BUILD_TIME=$BUILD_TIME" >> "$GITHUB_OUTPUT"
echo "BUILD_VERSION=$BUILD_VERSION" >> "$GITHUB_OUTPUT"
outputs:
BUILD_COMMIT: ${{ steps.main.outputs.BUILD_COMMIT }}
BUILD_COMMIT_TS: ${{ steps.main.outputs.BUILD_COMMIT_TS }}
BUILD_TIME: ${{ steps.main.outputs.BUILD_TIME }}
BUILD_VERSION: ${{ steps.main.outputs.BUILD_VERSION }}
REACT_APP_BUILD_VERSION: ${{ steps.main.outputs.REACT_APP_BUILD_VERSION }}
ref: ${{ steps.main.outputs.BUILD_COMMIT }}
ref_timestamp: ${{ steps.main.outputs.BUILD_COMMIT_TS }}
timestamp: ${{ steps.main.outputs.BUILD_TIME }}
version: ${{ steps.main.outputs.BUILD_VERSION }}
front:
if: ${{ false }} # disable
needs: env
runs-on: ubuntu-latest
container:
Expand All @@ -34,64 +34,79 @@ jobs:
- uses: actions/checkout@v4
with:
repository: VKCOM/statshouse
ref: ${{needs.env.outputs.BUILD_COMMIT}}
ref: ${{needs.env.outputs.ref}}
fetch-depth: 0
- run: |
REACT_APP_BUILD_VERSION=${{needs.env.outputs.BUILD_VERSION}}-${{needs.env.outputs.BUILD_TIME}}
REACT_APP_BUILD_VERSION=${{needs.env.outputs.version}}-${{needs.env.outputs.timestamp}}
make build-sh-ui
- uses: actions/upload-artifact@v3
with:
name: statshouse-${{needs.env.outputs.BUILD_VERSION}}-ui
name: statshouse-${{needs.env.outputs.version}}-ui
path: |
statshouse-ui/build
.dummy_preserves_directory_structure
- run: make build-grafana-ui
- uses: actions/upload-artifact@v3
with:
name: statshouse-${{needs.env.outputs.BUILD_VERSION}}-ui
name: statshouse-${{needs.env.outputs.version}}-ui
path: |
grafana-plugin-ui/dist
.dummy_preserves_directory_structure
debian:
if: ${{ false }} # disable
strategy:
matrix:
release: [buster, bullseye]
needs: [env, front]
uses: alpinskiy/statshouse-ppa/.github/workflows/build_deb.yml@master
uses: ./.github/workflows/build_deb.yml
with:
build_time: ${{needs.env.outputs.BUILD_TIME}}
build_commit: ${{needs.env.outputs.BUILD_COMMIT}}
build_commit_ts: ${{needs.env.outputs.BUILD_COMMIT_TS}}
build_version: ${{needs.env.outputs.BUILD_VERSION}}
build_container: '{"image": "golang:1.19-${{matrix.release}}"}'
os_name: 'debian'
os_release: ${{matrix.release}}
ref: ${{needs.env.outputs.ref}}
ref_timestamp: ${{needs.env.outputs.ref_timestamp}}
timestamp: ${{needs.env.outputs.timestamp}}
version: ${{needs.env.outputs.version}}
container: '{"image": "golang:1.19-${{matrix.release}}"}'
name: 'debian'
release: ${{matrix.release}}
secrets: inherit
ubuntu_jammy:
if: ${{ false }} # disable
needs: [env, front]
uses: alpinskiy/statshouse-ppa/.github/workflows/build_deb.yml@master
uses: ./.github/workflows/build_deb.yml
with:
build_time: ${{needs.env.outputs.BUILD_TIME}}
build_commit: ${{needs.env.outputs.BUILD_COMMIT}}
build_commit_ts: ${{needs.env.outputs.BUILD_COMMIT_TS}}
build_version: ${{needs.env.outputs.BUILD_VERSION}}
build_machine: ubuntu-22.04
os_name: ubuntu
os_release: jammy
ref: ${{needs.env.outputs.ref}}
ref_timestamp: ${{needs.env.outputs.ref_timestamp}}
timestamp: ${{needs.env.outputs.timestamp}}
version: ${{needs.env.outputs.version}}
name: ubuntu
release: jammy
runs-on: ubuntu-22.04
secrets: inherit
ubuntu_focal:
if: ${{ false }} # disable
needs: [env, front]
uses: alpinskiy/statshouse-ppa/.github/workflows/build_deb.yml@master
uses: ./.github/workflows/build_deb.yml
with:
build_time: ${{needs.env.outputs.BUILD_TIME}}
build_commit: ${{needs.env.outputs.BUILD_COMMIT}}
build_commit_ts: ${{needs.env.outputs.BUILD_COMMIT_TS}}
build_version: ${{needs.env.outputs.BUILD_VERSION}}
build_machine: ubuntu-20.04
os_name: ubuntu
os_release: focal
ref: ${{needs.env.outputs.ref}}
ref_timestamp: ${{needs.env.outputs.ref_timestamp}}
timestamp: ${{needs.env.outputs.timestamp}}
version: ${{needs.env.outputs.version}}
runs-on: ubuntu-20.04
name: ubuntu
release: focal
secrets: inherit
almalinux:
needs: [env]
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
secrets: inherit
draft_release:
if: ${{ false }} # disable
needs: [env, debian, ubuntu_jammy, ubuntu_focal]
runs-on: ubuntu-latest
steps:
Expand All @@ -101,7 +116,7 @@ jobs:
fetch-depth: 0
- uses: actions/download-artifact@master
with:
name: statshouse-${{needs.env.outputs.BUILD_VERSION}}_amd64-deb
- run: gh release create --draft --generate-notes --title "Release ${{needs.env.outputs.BUILD_VERSION}}" $(find -type f -name *.deb)
name: statshouse-${{needs.env.outputs.version}}_amd64-deb
- run: gh release create --draft --generate-notes --title "Release ${{needs.env.outputs.version}}" $(find -type f -name *.deb)
env:
GITHUB_TOKEN: ${{secrets.DEVTOOLS_GITHUB_TOKEN}}
53 changes: 53 additions & 0 deletions .github/workflows/build_binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
on:
workflow_call:
inputs:
ref:
required: true
type: string
ref_timestamp:
required: true
type: string
timestamp:
required: true
type: string
version:
required: true
type: string
container:
required: true
type: string
name:
required: true
type: string
release:
required: true
type: string
jobs:
binary:
runs-on: ubuntu-latest
container: ${{fromJSON(inputs.container)}}
steps:
- uses: actions/checkout@v4
with:
repository: VKCOM/statshouse
ref: ${{inputs.ref}}
fetch-depth: 0
- uses: actions/setup-go@v4
if: inputs.container == '{"image":null}'
with:
go-version: '1.19'
- uses: actions/download-artifact@master
if: ${{ false }} # disable
with:
name: statshouse-${{inputs.version}}-ui
- run: |
BUILD_TIME=${{inputs.timestamp}}
BUILD_COMMIT=${{inputs.ref}}
BUILD_COMMIT_TS=${{inputs.ref_timestamp}}
BUILD_MACHINE=$(uname -n -m -r -s)
BUILD_VERSION=${{inputs.version}}
make build-sh build-sh-metadata build-sh-api build-sh-grafana
- uses: actions/upload-artifact@v3
with:
name: statshouse-${{inputs.version}}-${{inputs.name}}_${{inputs.release}}_amd64-bin
path: target
58 changes: 29 additions & 29 deletions .github/workflows/build_deb.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
on:
workflow_call:
inputs:
build_time:
ref:
required: true
type: string
build_commit:
ref_timestamp:
required: true
type: string
build_commit_ts:
timestamp:
required: true
type: string
build_version:
version:
required: true
type: string
build_machine:
runs-on:
required: false
type: string
default: ubuntu-22.04
build_container:
default: ubuntu-latest
container:
required: false
type: string
default: '{"image":null}'
os_name:
name:
required: true
type: string
os_release:
release:
required: true
type: string
jobs:
binary:
runs-on: ${{inputs.build_machine}}
container: ${{fromJSON(inputs.build_container)}}
runs-on: ${{inputs.runs-on}}
container: ${{fromJSON(inputs.container)}}
steps:
- uses: actions/checkout@v4
with:
repository: VKCOM/statshouse
ref: ${{inputs.build_commit}}
ref: ${{inputs.ref}}
fetch-depth: 0
- uses: actions/setup-go@v4
if: inputs.build_container == '{"image":null}'
if: inputs.container == '{"image":null}'
with:
go-version: '1.19'
- uses: actions/download-artifact@master
with:
name: statshouse-${{inputs.build_version}}-ui
name: statshouse-${{inputs.version}}-ui
- run: |
BUILD_TIME=${{inputs.build_time}}
BUILD_COMMIT=${{inputs.build_commit}}
BUILD_COMMIT_TS=${{inputs.build_commit_ts}}
BUILD_TIME=${{inputs.timestamp}}
BUILD_COMMIT=${{inputs.ref}}
BUILD_COMMIT_TS=${{inputs.ref_timestamp}}
BUILD_MACHINE=$(uname -n -m -r -s)
BUILD_VERSION=${{inputs.build_version}}
BUILD_VERSION=${{inputs.version}}
cp -r statshouse-ui/build cmd/statshouse-api/
make build-sh build-sh-metadata build-sh-api build-sh-grafana
- uses: actions/upload-artifact@v3
with:
name: statshouse-${{inputs.build_version}}-${{inputs.os_name}}_${{inputs.os_release}}_amd64-bin
name: statshouse-${{inputs.version}}-${{inputs.name}}_${{inputs.release}}_amd64-bin
path: target
package:
needs: [binary]
Expand All @@ -67,30 +67,30 @@ jobs:
- uses: actions/checkout@v4
with:
repository: VKCOM/statshouse
ref: ${{inputs.build_commit}}
ref: ${{inputs.ref}}
fetch-depth: 0
- uses: actions/download-artifact@master
with:
name: statshouse-${{inputs.build_version}}-${{inputs.os_name}}_${{inputs.os_release}}_amd64-bin
name: statshouse-${{inputs.version}}-${{inputs.name}}_${{inputs.release}}_amd64-bin
path: target
- run: chmod +x target/*
- uses: actions/download-artifact@master
with:
name: statshouse-${{inputs.build_version}}-ui
name: statshouse-${{inputs.version}}-ui
- working-directory: build
run: |
rm -f changelog
VERSION=1:${{inputs.build_version}}-${{inputs.os_release}}
VERSION=1:${{inputs.version}}-${{inputs.release}}
dch --create --distribution stable --package statshouse --newversion "$VERSION" "up to version $VERSION"
debuild --no-lintian -us -uc -b
- run: |
mkdir -p ${{inputs.os_name}}/${{inputs.os_release}}
mv *.deb ${{inputs.os_name}}/${{inputs.os_release}}
mkdir -p ${{inputs.name}}/${{inputs.release}}
mv *.deb ${{inputs.name}}/${{inputs.release}}
- uses: actions/upload-artifact@v3
with:
name: statshouse-${{inputs.build_version}}_amd64-deb
name: statshouse-${{inputs.version}}_amd64-deb
path: |
${{inputs.os_name}}/${{inputs.os_release}}/statshouse_*
${{inputs.os_name}}/${{inputs.os_release}}/statshouse-api_*
${{inputs.os_name}}/${{inputs.os_release}}/statshouse-metadata_*
${{inputs.name}}/${{inputs.release}}/statshouse_*
${{inputs.name}}/${{inputs.release}}/statshouse-api_*
${{inputs.name}}/${{inputs.release}}/statshouse-metadata_*
.dummy_preserves_directory_structure
72 changes: 72 additions & 0 deletions .github/workflows/build_rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
on:
workflow_call:
inputs:
container:
required: false
type: string
default: '{"image":"almalinux:latest"}'
ref:
required: true
type: string
ref_timestamp:
required: true
type: string
timestamp:
required: true
type: string
version:
required: true
type: string
name:
required: true
type: string
release:
required: true
type: string
jobs:
binary:
uses: ./.github/workflows/build_binaries.yml
with:
container: ${{inputs.container}}
ref: ${{inputs.ref}}
ref_timestamp: ${{inputs.ref_timestamp}}
timestamp: ${{inputs.timestamp}}
version: ${{inputs.version}}
name: ${{inputs.name}}
release: ${{inputs.release}}
package:
needs: [binary]
runs-on: ubuntu-latest
container: ${{fromJSON(inputs.container)}}
steps:
- run: |
sudo dnf install -y epel-release
sudo dnf install -y rpm-build
- uses: actions/checkout@v4
with:
repository: VKCOM/statshouse
ref: ${{inputs.ref}}
fetch-depth: 0
- uses: actions/download-artifact@master
with:
name: statshouse-${{inputs.version}}-${{inputs.name}}_${{inputs.release}}_amd64-bin
path: target
- run: chmod +x target/*
- uses: actions/download-artifact@master
if: ${{ false }} # disable
with:
name: statshouse-${{inputs.version}}-ui
- run: |
mkdir -p statshouse-ui/build
make build-rpm
- run: |
mkdir -p ${{inputs.name}}/${{inputs.release}}
mv RPMS/**/*.rpm ${{inputs.name}}/${{inputs.release}}
- uses: actions/upload-artifact@v3
with:
name: statshouse-${{inputs.version}}_amd64-rpm
path: |
${{inputs.name}}/${{inputs.release}}/statshouse_*
${{inputs.name}}/${{inputs.release}}/statshouse-api_*
${{inputs.name}}/${{inputs.release}}/statshouse-metadata_*
.dummy_preserves_directory_structure
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ build-docker-sh-metadata:
build-deb:
./build/makedeb.sh

build-rpm:
rm -rf BUILD BUILDROOT SOURCES SPECS SRPMS RPMS
mkdir -p BUILD BUILDROOT SOURCES SPECS SRPMS RPMS
cp build/statshouse.spec SPECS/
rpmbuild --define "_topdir `pwd`" -bb SPECS/statshouse.spec
rm -rf BUILD BUILDROOT SOURCES SPECS SRPMS

# if tlgen is not installed, replace tlgen with full path, for example ~/go/src/gitlab.mvk.com/go/vkgo/projects/vktl/cmd/tlgen/tlgen
.PHONY: gen
gen:
Expand Down

0 comments on commit 6ee4e78

Please sign in to comment.