Skip to content

Update typescript-build-and-publish.yaml for Azure Pipelines (#442) #1366

Update typescript-build-and-publish.yaml for Azure Pipelines (#442)

Update typescript-build-and-publish.yaml for Azure Pipelines (#442) #1366

Workflow file for this run

name: GoBuildAndTest
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: cd go/tunnels && go build -v ./...
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Test
run: cd go/tunnels && go test -short -v ./...
check-version-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check Go SDK package version updated
run: |
SDK_DIR=go
FILE_WITH_PKG_VER=go/tunnels/tunnels.go
test -d $SDK_DIR && test -f $FILE_WITH_PKG_VER
BASE_SHA=$(jq -r '.pull_request.base.sha' "$GITHUB_EVENT_PATH")
# If go sdk dir updated, package version file updated and "PackageVersion" line updated, success; else error.
if git diff --name-only $BASE_SHA HEAD | grep -q "^$SDK_DIR"; then
if git diff --name-only $BASE_SHA HEAD | grep -q "^$FILE_WITH_PKG_VER" && git diff $BASE_SHA HEAD -- $FILE_WITH_PKG_VER | grep -q "PackageVersion"; then
echo "Success: Package version was updated."
exit 0
else
echo "Error: An error occurred. Has "PackageVersion" in $FILE_WITH_PKG_VER been updated?" >&2
exit 1
fi
else
echo "No Go SDK changes detected."
fi