Skip to content

Commit

Permalink
Test env setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tzununbekov committed Feb 20, 2024
1 parent 857ca78 commit 4f04de7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
56 changes: 39 additions & 17 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build packages
on:
workflow_call:
push:
branches: [master, ci-migration]
branches: [master]
tags:

# Mage's `GenerateEnvFile` talks to GH API to setup tags, versions, etc.
Expand All @@ -21,30 +21,46 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
fetch-depth: 0
fetch-tags: true

- name: Prepare environment
run: |
echo "BUILD_NUMBER=${{ github.repository }}-${{ github.workflow }}-${{ github.run_id }}-ghactions" >> $GITHUB_ENV
echo "BUILD_COMMIT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
echo "BUILD_BRANCH_SAFE=${{ github.ref }}" >> $GITHUB_ENV
echo "BUILD_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "BUILD_BRANCH=${{ github.ref }}" >> $GITHUB_ENV
RELEASE_BUILD=false
if [[ "${GITHUB_REF}" == /refs/tags/* ]]; then RELEASE_BUILD=true; fi
- name: Generate env file
run: go run mage.go -v GenerateEnvFile

# - name: Create bucket
# if: github.event_name == 'push'
# run: go run mage.go -v MakeBucket
RC_BUILD=false
if [[ "${GITHUB_REF}" == /refs/tags/*-rc ]]; then RC_BUILD=true; fi
SNAPSHOT_BUILD=false
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then SNAPSHOT_BUILD=true; fi
PR_BUILD=false
if [[ "${SNAPSHOT_BUILD}" == "false" && "${RELEASE_BUILD}" == "false" ]]; then PR_BUILD=true; fi
BUILD_NUMBER="${{ github.run_id }}"-ghactions
if [[ "${RELEASE_BUILD}" == "true" ]]; then
BUILD_VERSION="${GITHUB_REF#/refs/tags/}";
elif [[ "${SNAPSHOT_BUILD}" == "true" ]]; then
BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1snapshot-"$(date '+%Y%m%dT%H%M')"-"$(echo ${GITHUB_SHA} | cut -c1-8)";
elif [[ "${PR_BUILD}" == "true" ]]; then
BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1branch-"${GITHUB_HEAD_REF////-}";
fi
cat <<EOT >> env.sh
export RELEASE_BUILD=$RELEASE_BUILD;
export RC_BUILD=$RC_BUILD;
export SNAPSHOT_BUILD=$SNAPSHOT_BUILD;
export BUILD_NUMBER=$BUILD_NUMBER;
export BUILD_VERSION=$BUILD_VERSION;
EOT
- uses: actions/upload-artifact@v4
with:
name: env.sh
path: build/env.sh
path: env.sh

build-packages:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -76,6 +92,12 @@ jobs:
with:
name: env.sh

- name: Create bucket
if: contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
run: |
source env.sh
go run mage.go -v MakeBucket
- name: Setup FPM
run: |
sudo apt-get install ruby-dev build-essential
Expand All @@ -84,7 +106,7 @@ jobs:
- name: Build package
run: |
source env.sh
go run mage.go -v ${{ matrix.platform }}
CI=false go run mage.go -v ${{ matrix.platform }}
build-swagger:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests-and-linters.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Tests
# on:
# pull_request:
on:
pull_request:

env:
GOFLAGS: "-count=1"
Expand Down

0 comments on commit 4f04de7

Please sign in to comment.