Skip to content

.github/workflows/build.yml #139

.github/workflows/build.yml

.github/workflows/build.yml #139

Workflow file for this run

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build'
required: true
draft_release:
description: 'Draft a release'
required: false
default: true
jobs:
env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: VKCOM/statshouse
ref: ${{ github.event.inputs.tag }}
fetch-depth: 0
- id: main
run: |
BUILD_COMMIT=$(git log --format="%H" -n 1)
BUILD_COMMIT_TS=$(git log --format="%ct" -n 1)
BUILD_TIME=$(date +%FT%T%z)
BUILD_VERSION=$(git describe --tags --always --dirty)
BUILD_VERSION=${BUILD_VERSION#v}
echo "BUILD_COMMIT=$BUILD_COMMIT" >> "$GITHUB_OUTPUT"
echo "BUILD_COMMIT_TS=$BUILD_COMMIT_TS" >> "$GITHUB_OUTPUT"
echo "BUILD_TIME=$BUILD_TIME" >> "$GITHUB_OUTPUT"
echo "BUILD_VERSION=$BUILD_VERSION" >> "$GITHUB_OUTPUT"
outputs:
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 }}
frontend:
needs: env
runs-on: ubuntu-latest
container:
image: node:18
steps:
- uses: actions/checkout@v4
with:
repository: VKCOM/statshouse
ref: ${{needs.env.outputs.ref}}
fetch-depth: 0
- run: echo "REACT_APP_BUILD_VERSION=${{needs.env.outputs.version}}-${{needs.env.outputs.timestamp}}" >> $GITHUB_ENV
- run: make build-sh-ui
- uses: actions/upload-artifact@v4
with:
name: statshouse-ui-${{needs.env.outputs.version}}
path: |
statshouse-ui/build
.dummy_preserves_directory_structure
outputs:
artifact: statshouse-ui-${{needs.env.outputs.version}}
rpm:
strategy:
matrix:
image: ["centos:centos7", "almalinux:9"]
needs: [env, frontend]
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:
matrix:
release: [buster, bullseye]
needs: [env, frontend]
uses: ./.github/workflows/build_deb.yml
with:
container_json: '{"image":"golang:1.22-${{matrix.release}}"}'
ref: ${{needs.env.outputs.ref}}
ref_timestamp: ${{needs.env.outputs.ref_timestamp}}
timestamp: ${{needs.env.outputs.timestamp}}
version: ${{needs.env.outputs.version}}
name: 'debian'
release: ${{matrix.release}}
frontend-artifact: ${{needs.frontend.outputs.artifact}}
secrets: inherit
ubuntu_jammy:
if: ${{false}}
needs: [env, frontend]
uses: ./.github/workflows/build_deb.yml
with:
runs-on: ubuntu-22.04
setup-go: true
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
frontend-artifact: ${{needs.frontend.outputs.artifact}}
secrets: inherit
ubuntu_focal:
needs: [env, frontend]
uses: ./.github/workflows/build_deb.yml
with:
runs-on: ubuntu-20.04
setup-go: true
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: focal
frontend-artifact: ${{needs.frontend.outputs.artifact}}
secrets: inherit
draft_release:
if: ${{ github.event.inputs.draft_release }}
needs: [env, rpm, ubuntu_focal]
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:
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}}