Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amplify-preview go version #298

Merged
merged 53 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b090543
Setup env-loader CI/CD and dev tooling
fheinecke Nov 4, 2024
fef1952
Fix missing local dev tools
fheinecke Nov 4, 2024
0494689
Move reusable workflows under .github/workflows
fheinecke Nov 6, 2024
58a81d4
symlink reusable workflows
fheinecke Nov 6, 2024
d06b962
Bump linter for 1.23 compat
fheinecke Nov 6, 2024
c7023ae
set working dir
fheinecke Nov 6, 2024
e2ae333
fix building for windows arm64 instead of amd64
fheinecke Nov 6, 2024
f0866e4
Fix image builds
fheinecke Nov 6, 2024
a6abc83
Merge pull request #284 from gravitational/fred/env-loader-tooling-1
fheinecke Nov 6, 2024
9f8b8e9
env-loader: Allow for providing environments directory via arg
fheinecke Nov 6, 2024
f48d22e
Merge pull request #288 from gravitational/fred/env-loader-provide-dir-1
fheinecke Nov 6, 2024
983caa9
Fix tooling release issues
fheinecke Nov 12, 2024
5baf10c
Add missing token env var
fheinecke Nov 12, 2024
ca91609
typo fix
fheinecke Nov 12, 2024
fe70a4c
Fail release early if tag != makefile version
fheinecke Nov 12, 2024
723ac67
dir fix
fheinecke Nov 12, 2024
cae06a6
fd fix
fheinecke Nov 12, 2024
fa67c40
better error handling
fheinecke Nov 12, 2024
26252d6
set tag for testing
fheinecke Nov 12, 2024
8889a8a
RM tag changes
fheinecke Nov 12, 2024
df21eb0
Merge pull request #292 from gravitational/fred/release-fixes-1
fheinecke Nov 12, 2024
8444b88
Release env-loader v0.0.1
fheinecke Nov 12, 2024
4bd2c6c
Merge pull request #293 from gravitational/release/env-loader/v0.0.1
fheinecke Nov 12, 2024
0042f04
env-loader: bug fixes
fheinecke Nov 19, 2024
0d4ac38
Change the way docs approvals work
zmb3 Nov 18, 2024
cb392a5
Simplify
zmb3 Nov 19, 2024
c0b1c39
Add tests
fheinecke Nov 26, 2024
758ebab
parse -> mustparse
fheinecke Nov 26, 2024
cafadad
add missing error check
fheinecke Nov 26, 2024
7c3ac76
Address PR comments
fheinecke Nov 26, 2024
f433aa8
Merge pull request #295 from gravitational/fred/env-loader/bugfixes-1
fheinecke Nov 26, 2024
b6b0a07
Release env-loader v0.0.2
fheinecke Nov 26, 2024
0f1f9de
Merge pull request #296 from gravitational/release/env-loader/v0.0.2
fheinecke Nov 26, 2024
16b059d
Merge remote-tracking branch 'origin' into taras/amplify-preview-go
taraspos Dec 10, 2024
00f2aed
Create go version of amplify preview gha action
taraspos Dec 10, 2024
1f776e5
fix setup-go action
taraspos Dec 10, 2024
6f9a5d2
fix path
taraspos Dec 10, 2024
56b471a
pushd
taraspos Dec 10, 2024
0c33920
logging improvement
taraspos Dec 10, 2024
489b415
add github token env variable
taraspos Dec 10, 2024
48719d9
add repo name and owner
taraspos Dec 10, 2024
0b4ef3a
fix format
taraspos Dec 10, 2024
30f960d
Add log
taraspos Dec 10, 2024
3b0aac0
Fix comment matcher logic
taraspos Dec 10, 2024
d1d9e50
fix comma separated list of app ids
taraspos Dec 11, 2024
600661a
increase log level
taraspos Dec 11, 2024
f2a6fa3
close the channel properly
taraspos Dec 11, 2024
549fcbd
Fix not found exception
taraspos Dec 11, 2024
b6d379b
fix error handling
taraspos Dec 11, 2024
ad8257b
fix time panic
taraspos Dec 11, 2024
d835d23
Add checkbox to update preview status
taraspos Dec 11, 2024
2a6d70c
add one more newline
taraspos Dec 11, 2024
cf9c32a
remove checkbox thingy
taraspos Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 6 additions & 115 deletions .github/workflows/changelog-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,122 +13,13 @@ on:
paths:
- tools/changelog/workflows/cd.yaml
- .github/workflows/changelog-cd.yaml

env:
TOOL_DIRECTORY: tools/changelog
- .github/workflows/reusable-cd.yaml

jobs:
release:
name: Release
runs-on: ubuntu-latest
uses: ./.github/workflows/reusable-cd.yaml
permissions:
contents: write # Needed to create the release
packages: write # Needed to upload the images to GHCR
steps:
# Setup
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create event-specific values
id: setup
run: |
# Determine if the workflow was triggered via a push to main or a tag
# and get the version based off of that
if [[ "${GITHUB_REF}" =~ refs/tags/.* ]]; then
# Transforms tag refs like refs/tags/tools/changelog/v1.2.3 into v1.2.3
echo "version=${GITHUB_REF#refs/tags/tools/changelog}" >> "${GITHUB_OUTPUT}"

# Eventually the parse-version action from the teleport.e repo
# should move into this repo and replace this logic
echo "should-release=true" >> "${GITHUB_OUTPUT}"

# Any '-' character means in a tag ref means that it is a prerelease
if [[ "${GITHUB_REF}" == *-* ]]; then
echo "is-prerelease=true" >> "${GITHUB_OUTPUT}"
fi
fi

# Build the binaries
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: '${{ env.TOOL_DIRECTORY }}/go.mod'

- name: Build the project
working-directory: ${{ env.TOOL_DIRECTORY }}
run: |
make tarball OS=linux ARCH=amd64
make tarball OS=linux ARCH=arm64
make tarball OS=darwin ARCH=amd64
make tarball OS=darwin ARCH=arm64
make tarball OS=windows ARCH=arm64

# Build and push the image
- name: Install docker buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3.4.0

- name: Login to GitHub Container Registry
id: login-ghcr
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare container image labels and tags
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: |
ghcr.io/${{ github.repository_owner }}/changelog
flavor: |
latest=false
# Enable sha tag on branch push events and pull requests.
# Enable semver tags on tag push events, but don't overwrite major/minor tags for prereleases.
# Semver tags won't be generated except upon tag events.
tags: |
type=sha,prefix=v0.0.0-{{branch}}-,enable=${{ startsWith(github.ref, 'refs/heads/') }}
type=sha,prefix=v0.0.0-{{base_ref}}-,enable=${{ github.event_name == 'pull_request' }}
type=semver,pattern={{major}},value=${{ steps.setup.outputs.version }},enable=${{ steps.setup.outputs.is-prerelease != 'true' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.setup.outputs.version }},enable=${{ steps.setup.outputs.is-prerelease != 'true' }}
type=semver,pattern={{version}},value=${{ steps.setup.outputs.version }}

- name: Build the container image and push
uses: docker/build-push-action@1ca370b3a9802c92e886402e0dd88098a2533b12 # v6.4.1
with:
context: ${{ env.TOOL_DIRECTORY }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: |
linux/amd64
linux/arm64
provenance: true
sbom: true

# File a new release with the tarballs attached
- name: Create a new GitHub release
if: ${{ steps.setup.outputs.should-release == 'true' }}
working-directory: ${{ env.TOOL_DIRECTORY }}
env:
VERSION: ${{ steps.setup.outputs.version }}
IS_PRERELEASE: ${{ steps.setup.outputs.is-prerelease }}
run: |
if [[ "${IS_PRERELEASE}" == 'true' ]]; then
EXTRA_FLAGS=("--prerelease")
else
EXTRA_FLAGS=("--latest")
fi

readarray -d '' RELEASE_TARBALLS < <(
find . -name '*.tar.gz' -print0
)

echo "Creating a release for ${VERSION} with files:"
ls -lh "${RELEASE_TARBALLS[@]}"

gh release create --title "changelog ${VERSION}" --verify-tag \
--generate-notes "${EXTRA_FLAGS[@]}" "${GITHUB_REF_NAME}" \
"${RELEASE_TARBALLS[@]}"
contents: write
packages: write
with:
tool-directory: ./tools/changelog
53 changes: 7 additions & 46 deletions .github/workflows/changelog-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,11 @@ name: Changelog generator CI
on:
pull_request:

env:
TOOL_DIRECTORY: tools/changelog

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
# Determine if tests should run
# This is a monorepo and GH checks cannot be required for only specific
# paths, so this is required instead of a trigger `paths` filter.
- name: Check if relavent files have changed
id: changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
filters: |
tool:
- 'tools/changelog/**'
- '.github/workflows/changelog-ci.yaml'

# Setup
- name: Checkout repository
if: steps.changes.outputs.tool == 'true'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
if: steps.changes.outputs.tool == 'true'
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: "${{ env.TOOL_DIRECTORY }}/go.mod"

# Linting
- name: Install golangci-lint
if: steps.changes.outputs.tool == 'true'
run: go install github.com/golangci/golangci-lint/cmd/[email protected]
- name: Lint
if: steps.changes.outputs.tool == 'true'
working-directory: ${{ env.TOOL_DIRECTORY }}
run: make lint

# Tests
- name: Install gotestsum
if: steps.changes.outputs.tool == 'true'
run: go install gotest.tools/[email protected]
- name: Run tests
if: steps.changes.outputs.tool == 'true'
working-directory: ${{ env.TOOL_DIRECTORY }}
run: make test
release:
uses: ./.github/workflows/reusable-ci.yaml
permissions:
contents: write
packages: write
with:
tool-directory: ./tools/changelog
25 changes: 25 additions & 0 deletions .github/workflows/env-loader-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Environment value loader CD

on:
push:
branches:
- main
paths:
- tools/env-loader
tags:
- "tools/env-loader/v[0-9]+.[0-9]+.[0-9]+**"
pull_request:
paths:
- tools/env-loader/workflows/cd.yaml
- .github/workflows/env-loader-cd.yaml
- .github/workflows/reusable-cd.yaml

jobs:
release:
uses: ./.github/workflows/reusable-cd.yaml
permissions:
contents: write
packages: write
with:
tool-directory: ./tools/env-loader
14 changes: 14 additions & 0 deletions .github/workflows/env-loader-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Environment value loader CI

on:
pull_request:

jobs:
release:
uses: ./.github/workflows/reusable-ci.yaml
permissions:
contents: write
packages: write
with:
tool-directory: ./tools/env-loader
149 changes: 149 additions & 0 deletions .github/workflows/reusable-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
---
on:
workflow_call:
inputs:
tool-directory:
type: string
description: Path to the tool's directory, relative to repo root
dockerfile-path:
type: string
description: Path to the tool's dockerfile, relative to repo root
default: ./tools/repo-release-tooling/Dockerfile

jobs:
release:
name: Release
runs-on: ubuntu-22.04-8core
permissions:
contents: write # Needed to create the release
packages: write # Needed to upload the images to GHCR
steps:
# Setup
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Get the name of the tool
working-directory: ${{ inputs.tool-directory }}
run: set -euo pipefail; echo "TOOL_NAME=$(make print-tool-name)" >> "${GITHUB_ENV}"
- name: Create event-specific values
id: setup
working-directory: ${{ inputs.tool-directory }}
run: |
set -euo pipefail
# Determine if the workflow was triggered via a push to main or a tag
# and get the version based off of that
if [[ "${GITHUB_REF}" =~ refs/tags/.* ]]; then
# Transforms tag refs like refs/tags/tools/${TOOL_NAME}/v1.2.3 into v1.2.3
VERSION="${GITHUB_REF#refs/tags/tools/${TOOL_NAME}/}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"

# Eventually the parse-version action from the teleport.e repo
# should move into this repo and replace this logic
echo "should-release=true" >> "${GITHUB_OUTPUT}"

# Any '-' character in the version means that it is a prerelease
if [[ "${VERSION}" == *-* ]]; then
echo "is-prerelease=true" >> "${GITHUB_OUTPUT}"
fi

# Verify that the tag version matches the tool version
MAKEFILE_VERSION="$(make print-version)"
if [[ "${MAKEFILE_VERSION}" != "${VERSION}" ]]; then
echo "Makefile version '${MAKEFILE_VERSION}' does not match tag '${VERSION}'" >&2
exit 1
fi
fi

# Build the binaries
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: "${{ inputs.tool-directory }}/go.mod"
cache-dependency-path: "${{ inputs.tool-directory }}/go.sum"

- name: Build the project
working-directory: ${{ inputs.tool-directory }}
run: |
set -euo pipefail
make tarball OS=linux ARCH=amd64
make tarball OS=linux ARCH=arm64
make tarball OS=darwin ARCH=amd64
make tarball OS=darwin ARCH=arm64
make tarball OS=windows ARCH=amd64

# Build and push the image
- name: Install docker buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3.4.0

- name: Login to GitHub Container Registry
id: login-ghcr
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# TODO move this to `make container-image` or similar.
# Using these to actions for now because they greatly reduce the amount
# of in-house logic required
- name: Prepare container image labels and tags
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.TOOL_NAME }}
flavor: |
latest=false
# Enable sha tag on branch push events and pull requests.
# Enable semver tags on tag push events, but don't overwrite major/minor tags for prereleases.
# Semver tags won't be generated except upon tag events.
tags: |
type=sha,prefix=v0.0.0-{{branch}}-,enable=${{ startsWith(github.ref, 'refs/heads/') }}
type=sha,prefix=v0.0.0-{{base_ref}}-,enable=${{ github.event_name == 'pull_request' }}
type=semver,pattern={{major}},value=${{ steps.setup.outputs.version }},enable=${{ steps.setup.outputs.is-prerelease != 'true' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.setup.outputs.version }},enable=${{ steps.setup.outputs.is-prerelease != 'true' }}
type=semver,pattern={{version}},value=${{ steps.setup.outputs.version }}

- name: Build the container image and push
uses: docker/build-push-action@1ca370b3a9802c92e886402e0dd88098a2533b12 # v6.4.1
with:
context: ${{ inputs.tool-directory }}
file: ${{ inputs.dockerfile-path }}
build-args: TOOL_NAME=${{ env.TOOL_NAME }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: |
linux/amd64
linux/arm64
provenance: true
sbom: true

# File a new release with the tarballs attached
- name: Create a new GitHub release
if: ${{ steps.setup.outputs.should-release == 'true' }}
working-directory: ${{ inputs.tool-directory }}
env:
VERSION: ${{ steps.setup.outputs.version }}
IS_PRERELEASE: ${{ steps.setup.outputs.is-prerelease }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
if [[ "${IS_PRERELEASE}" == 'true' ]]; then
EXTRA_FLAGS=("--prerelease")
else
EXTRA_FLAGS=("--latest")
fi

readarray -d '' RELEASE_TARBALLS < <(
find . -name '*.tar.gz' -print0
)

echo "Creating a release for ${VERSION} with files:"
ls -lh "${RELEASE_TARBALLS[@]}"

gh release create --title "${TOOL_NAME} ${VERSION}" --verify-tag \
--generate-notes "${EXTRA_FLAGS[@]}" "${GITHUB_REF_NAME}" \
"${RELEASE_TARBALLS[@]}"
Loading
Loading