Skip to content

Cut v2.9.0 release (#188) #464

Cut v2.9.0 release (#188)

Cut v2.9.0 release (#188) #464

Workflow file for this run

name: main
on:
push:
pull_request:
release:
types: [created]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.21
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Lint, test and build
run: |
# Get staticcheck
export PATH=$PATH:$(go env GOPATH)/bin
go install honnef.co/go/tools/cmd/staticcheck@v0.4.3
# Lint and test
make lint
make format
# Exit if after formatting there are any code differences
git diff --exit-code
make test
# Build
if [ ${{ github.event_name }} == "release" ]; then
# github.ref is in the form refs/tags/VERSION, so apply regex to just get version
VERSION=$(echo "${{ github.ref }}" | grep -P '([^\/]+$)' -o)
else
VERSION=$(git rev-parse --short ${{ github.sha }})
fi
make docker VERSION=${VERSION}
- name: Deploy
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
if: github.event_name != 'pull_request' && github.repository == 'jthomperoo/custom-pod-autoscaler'
run: |
# Array of images to publish
declare -a IMAGES=(python python-3-6 python-3-7 python-3-8 alpine openjdk-11)
echo "$DOCKER_PASS" | docker login --username=$DOCKER_USER --password-stdin
if [ ${{ github.event_name }} == "release" ]; then
# This needs to be determined again, due to env vars not being shared between steps
# https://github.com/actions/starter-workflows/issues/68
VERSION=$(echo "${{ github.ref }}" | grep -P '([^\/]+$)' -o)
# Go through each image type and publish each one individually
for image in "${IMAGES[@]}"; do
docker tag custompodautoscaler/${image}:${VERSION} custompodautoscaler/${image}:latest
docker push custompodautoscaler/${image}:${VERSION}
docker push custompodautoscaler/${image}:latest
done
# Package binary
tar -czvf custom-pod-autoscaler.tar.gz dist/*
else
for image in "${IMAGES[@]}"; do
docker push custompodautoscaler/${image}:$(git rev-parse --short ${{ github.sha }})
done
fi
- name: Deploy binary
if: github.event_name == 'release' && github.repository == 'jthomperoo/custom-pod-autoscaler'
uses: Shopify/upload-to-release@1.0.0
with:
name: custom-pod-autoscaler.tar.gz
path: custom-pod-autoscaler.tar.gz
repo-token: ${{ secrets.GITHUB_TOKEN }}