Skip to content

updated CI build system #129

updated CI build system

updated CI build system #129

Workflow file for this run

name: Cross Platform build
on: [push, pull_request]
env:
GOVERSION: '1.24'
jobs:
build_linux:
runs-on: ubuntu-22.04
strategy:
matrix:
version: ['linux-arm', 'linux-386', 'linux-amd64', 'windows-386', 'windows-amd64']
include:
# add the GO environment variables
- version: linux-arm
GOOS: linux
GOARCH: arm
- version: linux-386
GOOS: linux
GOARCH: '386'
- version: linux-amd64
GOOS: linux
GOARCH: amd64
- version: windows-386
GOOS: windows
GOARCH: '386'
- version: windows-amd64
GOOS: windows
GOARCH: amd64
steps:
-
name: Set up Go $GOVERSION
uses: actions/setup-go@v5
id: go
with:
go-version: ${{ env.GOVERSION }}
-
name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
-
name: Install dependencies
run: |
sudo apt install upx -y
make install-deps
-
name: switch to javascript production libraries
run: |
make js-production
-
name: Generate adapter code
run: |
export PATH=/home/runner/go/bin:$PATH
make generate
-
name: Compile
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
run: make dist
-
name: Prepare build artifact for stashing
run: |
mkdir release
mv ./remoteRotator* ./release
-
# The build artifact can be identified by the trailing sha of the git commit
name: Stash the build artifact
uses: actions/upload-artifact@v4
with:
name: remoteRotator-${{ matrix.GOOS }}-${{ matrix.GOARCH }}-${{ github.sha }}
path: ./release
build_macos:
runs-on: macos-latest
# runs-on: macos-11.0
strategy:
matrix:
version: ['macos-amd64', 'macos-arm64']
include:
- version: macos-amd64
GOOS: darwin
GOARCH: amd64
- version: macos-arm64
GOOS: darwin
GOARCH: arm64
steps:
-
name: Set up Go $GOVERSION
uses: actions/setup-go@v5
id: go
with:
go-version: ${{ env.GOVERSION }}
-
name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
-
name: Install dependencies
run: |
brew install upx
make install-deps
-
name: switch to javascript production libraries
run: |
make js-production
-
name: Generate adapter code
run: |
export PATH=/System/Volumes/Data/Users/runner/go/bin:$PATH
make generate
-
name: Compile
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
CGO_ENABLED: 1
run: |
SDKROOT=$(xcrun --sdk macosx --show-sdk-path) \
make dist
-
name: Prepare build artifact for stashing
run: |
mkdir release
mv ./remoteRotator ./release
-
# The build artifact can be identified by the trailing sha of the git commit
name: Stash the build artifact
uses: actions/upload-artifact@v4
with:
name: remoteRotator-${{ matrix.GOOS }}-${{ matrix.GOARCH }}-${{ github.sha }}
path: ./release
test_linux:
runs-on: ubuntu-22.04
steps:
-
name: Set up Go $GOVERSION
uses: actions/setup-go@v5
id: go
with:
go-version: ${{ env.GOVERSION }}
-
name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
-
name: Install dependencies
run: |
make install-deps
-
name: Generate adapter code
run: |
export PATH=/home/runner/go/bin:$PATH
make generate
-
# Test on the native platform (linux/amd64)
# Then upload the code coverage to Coveralls.io
name: Test
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
go test -race -covermode atomic -coverprofile=profile.cov ./...
go install github.com/mattn/goveralls@latest
$(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github
test_macos:
runs-on: macos-latest
# runs-on: macos-11.0
steps:
-
name: Set up Go $GOVERSION
uses: actions/setup-go@v5
id: go
with:
go-version: ${{ env.GOVERSION }}
-
name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
-
name: Install dependencies
run: |
make install-deps
-
name: Generate adapter code
run: |
export PATH=/System/Volumes/Data/Users/runner/go/bin:$PATH
make generate
-
name: Test (with race condition detector)
run: go test -v -race ./...
# A Github release is created whenever the git reference contains a tag, starting with 'v*' (e.g. v0.4.2)
# And the previous build jobs have been successful
create_release:
runs-on: ubuntu-22.04
needs: [build_linux, build_macos, test_linux, test_macos]
if: startsWith(github.ref, 'refs/tags/v')
steps:
-
name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false
-
# since jobs can not share any variables we have to copy the URL of the created Github release
# into a file and stash it as an artifact
name: Copy release URL into file
run: |
mkdir release
printf "%s" "${{ steps.create_release.outputs.upload_url }}" > release/url.txt
- name: Stash file containing the release URL as an artifact
uses: actions/upload-artifact@v1
with:
name: release-url
path: ./release
# In this job we upload the release artifacts to the corresponding release
create_release_and_upload:
runs-on: ubuntu-24.04
needs: [build_linux, build_macos, test_linux, test_macos]
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
version: ['linux-armhf', 'linux-i386', 'linux-amd64', 'darwin-amd64', 'darwin-arm64', 'windows-amd64', 'windows-i386']
# add the GO naming convention for OS ($GOOS) and architecture ($GOARCH)
# instead of using Linux' naming convention (version items).
include:
- version: linux-armhf
OS: linux
ARCH: arm
- version: linux-i386
OS: linux
ARCH: '386'
- version: linux-amd64
OS: linux
ARCH: amd64
- version: darwin-amd64
OS: darwin
ARCH: amd64
- version: darwin-arm64
OS: darwin
ARCH: arm64
- version: windows-amd64
OS: windows
ARCH: amd64
- version: windows-i386
OS: windows
ARCH: '386'
steps:
# Since Github actions (currently) doesn't provide a slugged version of the git tag we have to
# create it by ourselves. It is then made available to other steps in this job as a step.outputs
# variable
- name: Get the version (git tag)
id: get_version
run: |
echo ${GITHUB_REF/refs\/tags\//}
echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_ENV"
- name: Retrieve stashed intermediary build artifact
uses: actions/download-artifact@v4
with:
name: remoteRotator-${{ matrix.OS }}-${{ matrix.ARCH }}-${{ github.sha }}
# rename the retrieved intermediary artifact and prepare zip file
- name: Display current directory
run: pwd
- name: Display structure of downloaded files
run: ls -R
- name: Prepare release artifact
run: |
test -f ./remoteRotator && chmod +x ./remoteRotator #only on linux & darwin needed
zip -j remoteRotator-${{ env.VERSION_TAG }}-${{ matrix.OS }}-${{ matrix.ARCH }}.zip ./*
- name: Sleep a few seconds to avoid multiple releases with the same tag
run: |
RANDOM_DELAY=$(( ( RANDOM % 60 ) + 1 ))
sleep $RANDOM_DELAY