Skip to content

Commit

Permalink
Add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstairs committed Oct 6, 2023
1 parent 262f851 commit 04472d3
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 5 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Tyger
on:
push:
branches: [main]
tags: ["v*.*.*"]
pull_request: # all branches
workflow_dispatch:

Expand Down Expand Up @@ -209,3 +210,40 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

release:
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
needs:
- tyger-build-deploy
- windows-smoke-tests
- codeQL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: 'cli/go.mod'

- uses: cue-lang/[email protected]
with:
version: v0.6.0
name: install CUE

- name: get container registry
run: |
set -euo pipefail
official_container_registry=$(scripts/get-context-environment-config.sh -e developerConfig.officialContainerRegistry.fqdn)
echo "OFFICIAL_CONTAINER_REGISTRY=$(echo $official_container_registry)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: v1.21.2
workdir: cli
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

dist/
57 changes: 57 additions & 0 deletions cli/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
before:
hooks:
- go mod tidy

builds:
- id: tyger
main: ./cmd/tyger
binary: tyger
env:
- CGO_ENABLED=0
ldflags:
- -s -w
- -X main.version={{.Tag}}
- -X github.com/microsoft/tyger/cli/internal/install.containerRegistry={{ .Env.OFFICIAL_CONTAINER_REGISTRY }}
goos:
- linux
- windows
- darwin

- id: tyger-proxy
main: ./cmd/tyger-proxy
binary: tyger-proxy
env:
- CGO_ENABLED=0
ldflags:
- -s -w
- -X main.version={{.Tag}}
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
draft: true
replace_existing_draft: true
12 changes: 7 additions & 5 deletions scripts/get-context-environment-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ this_dir=$(dirname "${0}")
config_dir="${TYGER_ENVIRONMENT_CONFIG_DIR:-${this_dir}/../deploy/config/microsoft}"
helm_chart_dir=$(readlink -f "${this_dir}/../deploy/helm")

environment_name="${TYGER_ENVIRONMENT_NAME:-}"
if [[ -z "${environment_name:-}" ]]; then
if [[ "$expression" == "config" || "$expression" == config.* ]]; then
environment_name="${TYGER_ENVIRONMENT_NAME:-}"
if [[ -z "${environment_name:-}" ]]; then
if [[ ! "$(git config user.email)" =~ [^@]+ ]]; then
>&2 echo "git email is not set"
exit 1
echo >&2 "Set the TYGER_ENVIRONMENT_NAME environment variable or ensure your git email is set"
exit 1
fi
environment_name="${BASH_REMATCH[0]//[.\-_]/}"
fi
fi

cd "${config_dir}"
cue export . --out "${output}" -t environmentName="${environment_name}" -t tygerHelmChartDir="${helm_chart_dir}" -e "${expression}"
cue export . --out "${output}" -t environmentName="${environment_name:-}" -t tygerHelmChartDir="${helm_chart_dir}" -e "${expression}"

0 comments on commit 04472d3

Please sign in to comment.