Skip to content

Commit

Permalink
Update build pipeline - 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Bornholm authored and Ben Bornholm committed Dec 28, 2021
1 parent a731876 commit 5db4c93
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Upload osctrl bianries
uses: actions/upload-artifact@v2
with:
name: osctrl-${{ matrix.components }}-${{ steps.vars.outputs.branch }}-${{ steps.vars.outputs.sha_short }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
name: osctrl-${{ matrix.components }}-${{ steps.vars.outputs.branch }}-${{ steps.vars.outputs.sha_short }}-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin

- name: Create ZIP of build artifacts
Expand Down
81 changes: 48 additions & 33 deletions .github/workflows/tagged-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,36 @@ on:
- 'v*'

jobs:
build_and_test:
runs-on: ubuntu-20.04
strategy:
matrix:
components: ['tls', 'admin', 'api', 'cli']
goos: ['linux']
goarch: ['amd64']
steps:
######################################## Checkout code ########################################
- name: Checkout code
uses: actions/checkout@v2
######################################## Install go ########################################
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- run: go version
######################################## Get GO deps ########################################
- name: Get GO deps
run: go mod download
######################################## Build osctrl binaries ########################################
- name: Build osctrl-tls
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin ./${{ matrix.components }}
######################################## Upload artifacts ########################################
- name: Upload osctrl bianries
uses: actions/upload-artifact@v2
with:
name: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
path: ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
# build_and_test:
# runs-on: ubuntu-20.04
# strategy:
# matrix:
# components: ['tls', 'admin', 'api', 'cli']
# goos: ['linux']
# goarch: ['amd64']
# steps:
# ######################################## Checkout code ########################################
# - name: Checkout code
# uses: actions/checkout@v2
# ######################################## Install go ########################################
# - name: Set up Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.17
# - run: go version
# ######################################## Get GO deps ########################################
# - name: Get GO deps
# run: go mod download
# ######################################## Build osctrl binaries ########################################
# - name: Build osctrl-tls
# run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin ./${{ matrix.components }}
# ######################################## Upload artifacts ########################################
# - name: Upload osctrl bianries
# uses: actions/upload-artifact@v2
# with:
# name: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
# path: ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
release:
needs: [build_and_test]
runs-on: ubuntu-20.04
strategy:
matrix:
Expand All @@ -45,13 +44,29 @@ jobs:
goarch: ['amd64']
steps:
######################################## Download artifacts ########################################
- name: Download osctrl bianries
# https://newbedev.com/getting-current-branch-and-commit-hash-in-github-action
- name: Declare GIT hash and branch
id: vars
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo ::set-output name=version::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Download osctrl binaries
uses: actions/download-artifact@v2
with:
name: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
name: osctrl-${{ matrix.components }}-${{ steps.vars.outputs.branch }}-${{ steps.vars.outputs.sha_short }}-${{ matrix.goos }}-${{ matrix.goarch }}

- name: Rename binaries
run: |
mv osctrl-${{ matrix.components }}-${{ steps.vars.outputs.branch }}-${{ steps.vars.outputs.sha_short }}-${{ matrix.goos }}-${{ matrix.goarch }} \
osctrl-${{ matrix.components }}-${{ steps.vars.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}
######################################## Add binaries to release ########################################
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
#body_path: ${{ github.workspace }}-CHANGELOG.txt
files: osctrl-${{ matrix.components }}-${{ steps.vars.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin

0 comments on commit 5db4c93

Please sign in to comment.