Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve build pipeline #8

Merged
merged 2 commits into from
Jun 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 9 additions & 79 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
name: Build

on:
push:
pull_request:
branches: ["*"]
tags-ignore:
- build-*
workflow_dispatch:
inputs:
increaseVersion:
description: "increase version - yes/no"
default: "yes"
required: false
on: [pull_request]

jobs:
test:
if: ${{ github.event_name != 'push' || contains(github.event.head_commit.message, '#build') || github.ref == 'refs/heads/main' }}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.18

Expand All @@ -34,68 +22,10 @@ jobs:
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Execute Tests
run: |
go test -v ./...
env:
GOPRIVATE: github.com/argonsecurity/*

build:
if: ${{ ( github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '#build') || (github.ref == 'refs/heads/main')) && !contains(github.event.head_commit.message, '#skip-build') }}
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Set Repo Envs
- name: Build
run: |
echo "status=failed" | tee -a $GITHUB_ENV
echo "git_repo_name=chain-bench" | tee -a $GITHUB_ENV

- name: Checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.9
with:
versionSpec: "5.6.7"

- name: Bump Version
if: "${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' }}"
run: |
echo "Increasing version"
git config user.name "GitHub Actions Bot"
git config user.email "<>"

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.9

- name: Set Version
run: |
if [[ "${{ github.event.inputs.increaseVersion}}" != "yes" || ! ${{ github.ref }} =~ refs/heads/(main|master)$ ]]; then
echo "Set GITVERSION by steps.gitversion.outputs.fullSemVer"
GITVERSION=${{ steps.gitversion.outputs.fullSemVer }}
else
echo "Set GITVERSION by Incrementing steps.gitversion.outputs.fullSemVer"
GITVERSION=${GitVersion_Major}.${GitVersion_Minor}.$((GitVersion_Patch+1))
fi
echo "gitversion=${GITVERSION}" | tee -a $GITHUB_ENV

- name: Commit Tag and Push
env:
TAG: ${{ env.gitversion }}
run: |
git tag "${TAG}" || true
git push --tags || true

- name: Configure git url
make

- name: Execute Tests
run: |
git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
make test