Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Setup Go generator for monorepo (fern-api#2943)
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney authored Feb 12, 2024
1 parent 4f5f66e commit 2f37a60
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 127 deletions.
8 changes: 6 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/generators/go"
schedule:
interval: "weekly"
30 changes: 30 additions & 0 deletions .github/workflows/go-generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: go

on:
pull_request:
paths:
- "generators/go/**"
branches:
- main
workflow_call:

jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Compile
working-directory: ./generators/go
run: go build ./...

test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Run Tests
working-directory: ./generators/go
run: make test
148 changes: 148 additions & 0 deletions .github/workflows/publish-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- "generators/java/spring/VERSION"
- "generators/typescript/sdk/VERSION"
- "generators/typescript/express/VERSION"
- "generators/go/VERSION"
workflow_dispatch:
inputs:
generator:
Expand All @@ -36,6 +37,9 @@ on:
- java-spring
- typescript-sdk
- typescript-express
- go-sdk
- go-model
- go-fiber

jobs:
versions-changed:
Expand All @@ -53,6 +57,9 @@ jobs:
spring: ${{ steps.filter.outputs.spring }}
ts-sdk: ${{ steps.filter.outputs.ts-sdk }}
ts-express: ${{ steps.filter.outputs.ts-express }}
go-sdk: ${{ steps.filter.outputs.go-sdk }}
go-model: ${{ steps.filter.outputs.go-model }}
go-fiber: ${{ steps.filter.outputs.go-fiber }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
Expand All @@ -71,6 +78,9 @@ jobs:
spring: 'generators/java/spring/VERSION'
ts-sdk: 'generators/typescript/sdk/VERSION'
ts-express: 'generators/typescript/express/VERSION'
go-sdk: 'generators/go/VERSION'
go-model: 'generators/go/VERSION'
go-fiber: 'generators/go/VERSION'
pydantic-model:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -733,3 +743,141 @@ jobs:
run: |
yarn workspace @fern-typescript/sdk-generator-cli dockerTagVersion:node "$VERSION"
docker push fernapi/fern-typescript-node-sdk:"$VERSION"
go-sdk:
runs-on: ubuntu-latest
needs: versions-changed
if: ${{ needs.versions-changed.outputs.go-sdk == 'true' || inputs.generator == 'go-sdk' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: fernapi
password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }}

- name: Build CLI
working-directory: ./generators/go
run: go build ./...

- name: Print Version
if: ${{ inputs.generator != 'go-sdk' }}
run: |
projectVersion=$(cat generators/go/VERSION)
echo $projectVersion
echo "VERSION=$projectVersion" >> $GITHUB_ENV
- name: Print Version Dev
if: ${{ inputs.generator == 'go-sdk' }}
run: |
projectVersion=$(cat generators/go/VERSION)
commitNumber=$(git log --oneline | wc -l )
sha_short=$(git rev-parse --short HEAD)
echo $projectVersion-$commitNumber-$sha_short
echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./generators/go
file: ./generators/go/docker/Dockerfile.sdk
platforms: linux/amd64,linux/arm64
push: true
tags: fernapi/fern-go-sdk:${{env.VERSION}}

go-model:
runs-on: ubuntu-latest
needs: versions-changed
if: ${{ needs.versions-changed.outputs.go-model == 'true' || inputs.generator == 'go-model' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: fernapi
password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }}

- name: Build CLI
working-directory: ./generators/go
run: go build ./...

- name: Print Version
if: ${{ inputs.generator != 'go-model' }}
run: |
projectVersion=$(cat generators/go/VERSION)
echo $projectVersion
echo "VERSION=$projectVersion" >> $GITHUB_ENV
- name: Print Version Dev
if: ${{ inputs.generator == 'go-model' }}
run: |
projectVersion=$(cat generators/go/VERSION)
commitNumber=$(git log --oneline | wc -l )
sha_short=$(git rev-parse --short HEAD)
echo $projectVersion-$commitNumber-$sha_short
echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./generators/go
file: ./generators/go/docker/Dockerfile.model
platforms: linux/amd64,linux/arm64
push: true
tags: fernapi/fern-go-model:${{env.VERSION}}

go-fiber:
runs-on: ubuntu-latest
needs: versions-changed
if: ${{ needs.versions-changed.outputs.go-fiber == 'true' || inputs.generator == 'go-fiber' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: fernapi
password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }}

- name: Build CLI
working-directory: ./generators/go
run: go build ./...

- name: Print Version
if: ${{ inputs.generator != 'go-fiber' }}
run: |
projectVersion=$(cat generators/go/VERSION)
echo $projectVersion
echo "VERSION=$projectVersion" >> $GITHUB_ENV
- name: Print Version Dev
if: ${{ inputs.generator == 'go-fiber' }}
run: |
projectVersion=$(cat generators/go/VERSION)
commitNumber=$(git log --oneline | wc -l )
sha_short=$(git rev-parse --short HEAD)
echo $projectVersion-$commitNumber-$sha_short
echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./generators/go
file: ./generators/go/docker/Dockerfile.fiber
platforms: linux/amd64,linux/arm64
push: true
tags: fernapi/fern-go-fiber:${{env.VERSION}}
61 changes: 0 additions & 61 deletions generators/go/.circleci/config.yml

This file was deleted.

34 changes: 0 additions & 34 deletions generators/go/.github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

6 changes: 0 additions & 6 deletions generators/go/.github/dependabot.yml

This file was deleted.

23 changes: 0 additions & 23 deletions generators/go/.github/workflows/ci.yml

This file was deleted.

Loading

0 comments on commit 2f37a60

Please sign in to comment.