Skip to content

Commit

Permalink
Merge branch 'master' into local-web-server
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmcintosh authored Feb 1, 2024
2 parents 6c76ecf + e609605 commit a04906e
Show file tree
Hide file tree
Showing 38 changed files with 1,169 additions and 268 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
32 changes: 19 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Ensure code formatting and style is consistent
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2

Expand All @@ -27,18 +31,19 @@ jobs:
if: startsWith(github.repository, 'spinnaker/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Prepare build variables
id: build_variables
run: |
echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/}
echo ::set-output name=VERSION::"${GITHUB_REF_NAME}-$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')"
echo ::set-output name=VERSION_WITHOUT_BRANCH::"$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')"
echo REPO="${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT
echo VERSION="${GITHUB_REF_NAME}-$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
echo VERSION_WITHOUT_BRANCH="$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: 1.17
- uses: actions/cache@v2
go-version-file: go.mod
cache: false
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -54,16 +59,17 @@ jobs:
run: |
GOARCH=amd64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ github.ref_name }}/${{ steps.build_variables.outputs.VERSION_WITHOUT_BRANCH }}/darwin/amd64/spin .
GOARCH=amd64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ github.ref_name }}/${{ steps.build_variables.outputs.VERSION_WITHOUT_BRANCH }}/linux/amd64/spin .
GOARCH=arm64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ github.ref_name }}/${{ steps.build_variables.outputs.VERSION_WITHOUT_BRANCH }}/linux/arm64/spin .
GOARCH=amd64 GOOS=windows go build -ldflags "${LDFLAGS}" -o dist/${{ github.ref_name }}/${{ steps.build_variables.outputs.VERSION_WITHOUT_BRANCH }}/windows/amd64/spin.exe .
GOARCH=arm64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ github.ref_name }}/${{ steps.build_variables.outputs.VERSION_WITHOUT_BRANCH }}/darwin/arm64/spin .
dist/${{ github.ref_name }}/${{ steps.build_variables.outputs.VERSION_WITHOUT_BRANCH }}/linux/amd64/spin --version
- name: Login to Google Cloud
uses: 'google-github-actions/auth@v0'
uses: 'google-github-actions/auth@v2'
# use service account flow defined at: https://github.com/google-github-actions/upload-cloud-storage#authenticating-via-service-account-key-json
with:
credentials_json: '${{ secrets.GAR_JSON_KEY }}'
- name: Upload spin CLI binaries to GCS
uses: 'google-github-actions/upload-cloud-storage@v0'
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
path: 'dist/'
destination: 'spinnaker-artifacts/spin'
Expand All @@ -72,7 +78,7 @@ jobs:
- name: Login to GAR
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/login-action@v1
uses: docker/login-action@v3
# use service account flow defined at: https://github.com/docker/login-action#service-account-based-authentication-1
with:
registry: us-docker.pkg.dev
Expand All @@ -81,7 +87,7 @@ jobs:
- name: Build and publish container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Ensure code formatting and style is consistent
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Prepare build variables
id: build_variables
run: |
echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/}
echo ::set-output name=VERSION::"$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')"
echo REPO="${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT
echo VERSION="$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: 1.17
- uses: actions/cache@v2
go-version-file: go.mod
cache: false
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -45,12 +50,13 @@ jobs:
run: |
GOARCH=amd64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/darwin/amd64/spin .
GOARCH=amd64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/linux/amd64/spin .
GOARCH=arm64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/linux/arm64/spin .
GOARCH=amd64 GOOS=windows go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/windows/amd64/spin.exe .
GOARCH=arm64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/darwin/arm64/spin .
dist/${{ steps.build_variables.outputs.VERSION }}/linux/amd64/spin --version
- name: Build container image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
Expand Down
51 changes: 28 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Ensure code formatting and style is consistent
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2

release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Assemble release info
Expand All @@ -32,20 +36,21 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
. .github/workflows/release_info.sh ${{ github.event.repository.full_name }}
echo ::set-output name=CHANGELOG::$(echo -e "${CHANGELOG}")
echo ::set-output name=SKIP_RELEASE::${SKIP_RELEASE}
echo ::set-output name=IS_CANDIDATE::${IS_CANDIDATE}
echo ::set-output name=RELEASE_VERSION::${RELEASE_VERSION}
echo CHANGELOG=$(echo -e "${CHANGELOG}") >> $GITHUB_OUTPUT
echo SKIP_RELEASE="${SKIP_RELEASE}" >> $GITHUB_OUTPUT
echo IS_CANDIDATE="${IS_CANDIDATE}" >> $GITHUB_OUTPUT
echo RELEASE_VERSION="${RELEASE_VERSION}" >> $GITHUB_OUTPUT
- name: Prepare build variables
id: build_variables
run: |
echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/}
echo ::set-output name=VERSION::"$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')"
echo REPO="${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT
echo VERSION="$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: 1.17
- uses: actions/cache@v2
go-version-file: go.mod
cache: false
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -61,20 +66,21 @@ jobs:
run: |
GOARCH=amd64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ steps.release_info.outputs.RELEASE_VERSION }}/darwin/amd64/spin .
GOARCH=amd64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ steps.release_info.outputs.RELEASE_VERSION }}/linux/amd64/spin .
GOARCH=arm64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ steps.release_info.outputs.RELEASE_VERSION }}/linux/arm64/spin .
GOARCH=amd64 GOOS=windows go build -ldflags "${LDFLAGS}" -o dist/${{ steps.release_info.outputs.RELEASE_VERSION }}/windows/amd64/spin.exe .
GOARCH=arm64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ steps.release_info.outputs.RELEASE_VERSION }}/darwin/arm64/spin .
dist/${{ steps.release_info.outputs.RELEASE_VERSION }}/linux/amd64/spin --version
- name: Login to Google Cloud
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: 'google-github-actions/auth@v0'
uses: 'google-github-actions/auth@v2'
# use service account flow defined at: https://github.com/google-github-actions/upload-cloud-storage#authenticating-via-service-account-key-json
with:
credentials_json: '${{ secrets.GAR_JSON_KEY }}'
- name: Upload spin CLI binaries to GCS
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: 'google-github-actions/upload-cloud-storage@v0'
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
path: 'dist/'
destination: 'spinnaker-artifacts/spin'
Expand Down Expand Up @@ -102,7 +108,7 @@ jobs:
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
# See: https://spinnaker.io/docs/setup/other_config/spin/
uses: 'google-github-actions/upload-cloud-storage@v0'
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
path: 'dist/latests'
destination: 'spinnaker-artifacts/spin'
Expand All @@ -111,7 +117,7 @@ jobs:
- name: Login to GAR
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/login-action@v1
uses: docker/login-action@v3
# use service account flow defined at: https://github.com/docker/login-action#service-account-based-authentication-1
with:
registry: us-docker.pkg.dev
Expand All @@ -120,10 +126,10 @@ jobs:
- name: Build and publish container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.slim
file: Dockerfile
push: true
build-args: |
"VERSION=${{ steps.release_info.outputs.RELEASE_VERSION }}"
Expand All @@ -133,13 +139,12 @@ jobs:
- name: Create release
if: steps.release_info.outputs.SKIP_RELEASE == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.event.repository.name }} ${{ github.ref }}
body: |
${{ steps.release_info.outputs.CHANGELOG }}
draft: false
name: ${{ github.event.repository.name }} ${{ github.ref_name }}
prerelease: ${{ steps.release_info.outputs.IS_CANDIDATE }}
tag_name: ${{ github.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
24 changes: 15 additions & 9 deletions .github/workflows/release_info.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#!/bin/bash -x

# Only look to the latest release to determine the previous tag -- this allows us to skip unsupported tag formats (like `version-1.0.0`)
export PREVIOUS_TAG=`curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'`
echo "PREVIOUS_TAG=$PREVIOUS_TAG"
export NEW_TAG=${GITHUB_REF/refs\/tags\//}
NEW_TAG=${GITHUB_REF/refs\/tags\//}
export NEW_TAG
echo "NEW_TAG=$NEW_TAG"
export CHANGELOG=`git log $NEW_TAG...$PREVIOUS_TAG --oneline`
# Glob match previous tags which should be format v1.2.3. Avoids Deck's npm tagging.
PREVIOUS_TAG=$(git describe --abbrev=0 --tags "${NEW_TAG}"^ --match 'v[0-9]*')
export PREVIOUS_TAG
echo "PREVIOUS_TAG=$PREVIOUS_TAG"
CHANGELOG=$(git log "$NEW_TAG"..."$PREVIOUS_TAG" --oneline)
export CHANGELOG
echo "CHANGELOG=$CHANGELOG"

#Format the changelog so it's markdown compatible
# Format the changelog so it's markdown compatible
CHANGELOG="${CHANGELOG//$'%'/%25}"
CHANGELOG="${CHANGELOG//$'\n'/%0A}"
CHANGELOG="${CHANGELOG//$'\r'/%0D}"

# If the previous release tag is the same as this tag the user likely cut a release (and in the process created a tag), which means we can skip the need to create a release
export SKIP_RELEASE=`[[ "$PREVIOUS_TAG" = "$NEW_TAG" ]] && echo "true" || echo "false"`
SKIP_RELEASE=$([[ "$PREVIOUS_TAG" = "$NEW_TAG" ]] && echo "true" || echo "false")
export SKIP_RELEASE

# https://github.com/fsaintjacques/semver-tool/blob/master/src/semver#L5-L14
NAT='0|[1-9][0-9]*'
Expand All @@ -28,8 +32,10 @@ SEMVER_REGEX="\
(\\+${FIELD}(\\.${FIELD})*)?$"

# Used in downstream steps to determine if the release should be marked as a "prerelease" and if the build should build candidate release artifacts
export IS_CANDIDATE=`[[ $NEW_TAG =~ $SEMVER_REGEX && ! -z ${BASH_REMATCH[4]} ]] && echo "true" || echo "false"`
IS_CANDIDATE=$([[ $NEW_TAG =~ $SEMVER_REGEX && -n ${BASH_REMATCH[4]} ]] && echo "true" || echo "false")
export IS_CANDIDATE

# This is the version string we will pass to the build, trim off leading 'v' if present
export RELEASE_VERSION=`[[ $NEW_TAG =~ $SEMVER_REGEX ]] && echo "${NEW_TAG:1}" || echo "${NEW_TAG}"`
RELEASE_VERSION=$([[ $NEW_TAG =~ $SEMVER_REGEX ]] && echo "${NEW_TAG:1}" || echo "${NEW_TAG}")
export RELEASE_VERSION
echo "RELEASE_VERSION=$RELEASE_VERSION"
Loading

0 comments on commit a04906e

Please sign in to comment.