Skip to content

Commit a458a77

Browse files
authored
Merge pull request #5 from sonatype-nexus-community/feat/generate-golang-library
feat: add configuration to build and publish generated API client in Go
2 parents 713ddbb + 2a38083 commit a458a77

File tree

4 files changed

+95
-87
lines changed

4 files changed

+95
-87
lines changed

.github/workflows/build.yaml

+29-29
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
env:
18-
OPEN_API_GENERATOR_VERSION: 'v7.9.0'
18+
OPEN_API_GENERATOR_VERSION: 'v7.10.0'
1919
PYTHON_VERSION_DEFAULT: '3.12'
2020
POETRY_VERSION: '1.8.1'
2121

@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
strategy:
2727
matrix:
28-
language: ['python', 'typescript']
28+
language: ['go', 'python', 'typescript']
2929
steps:
3030
- name: Checkout
3131
# see https://github.com/actions/checkout
@@ -50,33 +50,33 @@ jobs:
5050
path: out/${{ matrix.language }}
5151
key: '${{ matrix.language }}-${{ github.run_id }}'
5252

53-
# validate-go:
54-
# name: Validate Go Library
55-
# runs-on: ubuntu-latest
56-
# needs: generate-library-code
57-
58-
# steps:
59-
# - name: Setup Go
60-
# uses: actions/setup-go@v5
61-
# with:
62-
# go-version: 1.22
63-
64-
# - name: Get generated code from cache
65-
# uses: actions/cache/restore@v4
66-
# with:
67-
# path: out/go
68-
# key: 'go-${{ github.run_id }}'
69-
# fail-on-cache-miss: true
70-
71-
# - name: Build Go API Client
72-
# run: go build -v ./
73-
# working-directory: out/go
74-
75-
# - name: Install test dependencies & run generated tests
76-
# run: |
77-
# go get github.com/stretchr/testify/assert
78-
# go test -v ./test/
79-
# working-directory: out/go
53+
validate-go:
54+
name: Validate Go Library
55+
runs-on: ubuntu-latest
56+
needs: generate-library-code
57+
58+
steps:
59+
- name: Setup Go
60+
uses: actions/setup-go@v5
61+
with:
62+
go-version: 1.22
63+
64+
- name: Get generated code from cache
65+
uses: actions/cache/restore@v4
66+
with:
67+
path: out/go
68+
key: 'go-${{ github.run_id }}'
69+
fail-on-cache-miss: true
70+
71+
- name: Build Go API Client
72+
run: go build -v ./
73+
working-directory: out/go
74+
75+
- name: Install test dependencies & run generated tests
76+
run: |
77+
go get github.com/stretchr/testify/assert
78+
go test -v ./test/
79+
working-directory: out/go
8080

8181
validate-python:
8282
name: Validate Python Library

.github/workflows/release.yaml

+57-57
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
env:
14-
OPEN_API_GENERATOR_VERSION: 'v7.9.0'
14+
OPEN_API_GENERATOR_VERSION: 'v7.10.0'
1515
PYTHON_VERSION_DEFAULT: '3.12'
1616
POETRY_VERSION: '1.8.1'
1717
THIS_VERSION: $(echo "${{ github.ref_name }}" | cut -d 'v' -f2)
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
language: ['python', 'typescript']
25+
language: ['go', 'python', 'typescript']
2626
steps:
2727
- name: Checkout
2828
# see https://github.com/actions/checkout
@@ -47,63 +47,63 @@ jobs:
4747
path: out/${{ matrix.language }}
4848
key: '${{ matrix.language }}-${{ github.sha }}'
4949

50-
# release-go:
51-
# name: Release Go Library
52-
# runs-on: ubuntu-latest
53-
# needs: generate-library-code
50+
release-go:
51+
name: Release Go Library
52+
runs-on: ubuntu-latest
53+
needs: generate-library-code
5454

55-
# steps:
56-
# - name: Setup Go
57-
# uses: actions/setup-go@v5
58-
# with:
59-
# go-version: 1.22
60-
61-
# - name: Checkout Go Library Repository
62-
# uses: actions/checkout@v4
63-
# with:
64-
# repository: sonatype-nexus-community/nexus-repo-api-client-go
65-
# ref: main
66-
# token: ${{ secrets.GO_LIB_GH_ACTION_TOKEN }}
67-
# path: out/go
68-
69-
# - name: Setup git config
70-
# run: |
71-
# git config --global user.name "GitHub Actions"
72-
# git config --global user.email "<>"
73-
74-
# - name: Unstage all existing files
75-
# run: git rm -fr --ignore-unmatch *
76-
# working-directory: out/go
77-
78-
# - name: Get generated code from cache
79-
# uses: actions/cache/restore@v4
80-
# with:
81-
# path: out/go
82-
# key: 'go-${{ github.sha }}'
83-
# fail-on-cache-miss: true
84-
# - name: Validate Checked Out Library
85-
# run: ls -lR ${{ github.workspace }}
55+
steps:
56+
- name: Setup Go
57+
uses: actions/setup-go@v5
58+
with:
59+
go-version: 1.22
60+
61+
- name: Checkout Go Library Repository
62+
uses: actions/checkout@v4
63+
with:
64+
repository: sonatype-nexus-community/ossindex-api-client-go
65+
ref: main
66+
token: ${{ secrets.GO_LIB_GH_ACTION_TOKEN }}
67+
path: out/go
68+
69+
- name: Setup git config
70+
run: |
71+
git config --global user.name "GitHub Actions"
72+
git config --global user.email "<>"
73+
74+
- name: Unstage all existing files
75+
run: git rm -fr --ignore-unmatch *
76+
working-directory: out/go
77+
78+
- name: Get generated code from cache
79+
uses: actions/cache/restore@v4
80+
with:
81+
path: out/go
82+
key: 'go-${{ github.sha }}'
83+
fail-on-cache-miss: true
84+
- name: Validate Checked Out Library
85+
run: ls -lR ${{ github.workspace }}
8686

87-
# - name: Build Go API Client
88-
# run: go build -v ./
89-
# working-directory: out/go
90-
91-
# - name: Install test dependencies & run generated tests
92-
# run: |
93-
# go get github.com/stretchr/testify/assert
94-
# go test -v ./test/
95-
# working-directory: out/go
96-
97-
# - name: Commit, Tag and Push
98-
# if: ${{ github.ref_type == 'tag' }}
99-
# run: |
100-
# echo "BRANCH=${{ github.ref }}\nSHA=${{ github.sha }}" > GIT_VERSION
101-
# git add *
102-
# git commit -m "Automated Release v${{ env.THIS_VERSION }}"
103-
# git tag -a "${{ github.ref_name }}" -m "Automated Release v${{ env.THIS_VERSION }}"
104-
# git push
105-
# git push --tags
106-
# working-directory: out/go
87+
- name: Build Go API Client
88+
run: go build -v ./
89+
working-directory: out/go
90+
91+
- name: Install test dependencies & run generated tests
92+
run: |
93+
go get github.com/stretchr/testify/assert
94+
go test -v ./test/
95+
working-directory: out/go
96+
97+
- name: Commit, Tag and Push
98+
if: ${{ github.ref_type == 'tag' }}
99+
run: |
100+
echo "BRANCH=${{ github.ref }}\nSHA=${{ github.sha }}" > GIT_VERSION
101+
git add *
102+
git commit -m "Automated Release v${{ env.THIS_VERSION }}"
103+
git tag -a "${{ github.ref_name }}" -m "Automated Release v${{ env.THIS_VERSION }}"
104+
git push
105+
git push --tags
106+
working-directory: out/go
107107

108108
# release-java-webclient:
109109
# name: Release Java Webclient Library

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ This repository produces generated API Clients in various languages and framewor
3232

3333
| Language / Framework | Since | Public Package Link |
3434
| -------------------- | ---------------------- | ------------------- |
35-
| Python | 2025-11-15 | [![PyPI - Version](https://img.shields.io/pypi/v/ossindex-api-client)](https://pypi.org/project/ossindex-api-client/) |
35+
| Go | 2025-01-15 | [![go.dev reference](https://img.shields.io/badge/dynamic/json?color=blue&label=tag&query=name&url=https://api.razonyang.com/v1/github/tag/sonatype-nexus-community/ossindex-api-client-go)](https://pkg.go.dev/github.com/sonatype-nexus-community/ossindex-api-client-go) |
36+
| Python | 2024-11-15 | [![PyPI - Version](https://img.shields.io/pypi/v/ossindex-api-client)](https://pypi.org/project/ossindex-api-client/) |
3637
| Typescript (fetch) | 2023-05-22 | [![npm](https://img.shields.io/npm/v/%40sonatype%2Fossindex-api-client)](https://www.npmjs.com/package/@sonatype/ossindex-api-client) |
3738

3839
## Known Issues

go.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'!include': 'common.yaml'
2+
outputDir: /local/out/go
3+
generatorName: go
4+
gitRepoId: ossindex-api-client-go
5+
additionalProperties:
6+
goImportAlias: ossindex
7+
packageName: ossindex

0 commit comments

Comments
 (0)