Cut v2.11.0 release #485
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main | |
on: | |
push: | |
pull_request: | |
release: | |
types: [created] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- uses: actions/checkout@v4 | |
- name: Lint, test and build | |
run: | | |
# Get staticcheck | |
export PATH=$PATH:$(go env GOPATH)/bin | |
# 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-8 python-3-12 alpine) | |
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/[email protected] | |
with: | |
name: custom-pod-autoscaler.tar.gz | |
path: custom-pod-autoscaler.tar.gz | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |