-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(go): Publish @fern-api/go-dynamic-snippets (#5053)
- Loading branch information
Showing
10 changed files
with
128 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Publish @fern-api/go-dynamic-snippets | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The version of the library to publish." | ||
required: true | ||
type: string | ||
|
||
env: | ||
PACKAGE_NAME: "@fern-api/go-dynamic-snippets" | ||
GITHUB_TOKEN: ${{ secrets.FERN_GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.FERN_NPM_TOKEN }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
if: ${{ inputs.version != null }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
|
||
- name: 📥 Install | ||
uses: ./.github/actions/install | ||
|
||
- uses: bufbuild/[email protected] | ||
with: | ||
github_token: ${{ github.token }} | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "stable" | ||
|
||
- name: Install protoc-gen-openapi | ||
run: go install github.com/google/gnostic/cmd/[email protected] | ||
|
||
- name: 🧪 Build | ||
run: pnpm --filter=${{ env.PACKAGE_NAME }} compile | ||
|
||
- name: 🧪 Test | ||
run: pnpm --filter=${{ env.PACKAGE_NAME }} test | ||
|
||
- name: Publish @fern-api/go-dynamic-snippets | ||
run: | | ||
cd generators/go-v2/dynamic-snippets | ||
pnpm --filter=${{ env.PACKAGE_NAME }} dist ${{ inputs.version }} | ||
cd dist | ||
echo "//registry.npmjs.org/:_authToken=${{ env.NPM_TOKEN }}" > ~/.npmrc | ||
npm publish --access public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const packageJson = require("./package.json"); | ||
const tsup = require('tsup'); | ||
const { writeFile, rename } = require("fs/promises"); | ||
const path = require("path"); | ||
|
||
main(); | ||
|
||
async function main() { | ||
await tsup.build({ | ||
entry: ['src/**/*.ts', '!src/__test__'], | ||
format: ['cjs'], | ||
clean: true, | ||
minify: true, | ||
dts: true, | ||
outDir: 'dist', | ||
external: [ | ||
// Test dependencies should not be included in the published package. | ||
'@fern-api/go-formatter', | ||
'@fern-api/project-loader', | ||
'@fern-api/workspace-loader' | ||
], | ||
tsconfig: "./build.tsconfig.json" | ||
}); | ||
|
||
process.chdir(path.join(__dirname, "dist")); | ||
|
||
// The module expects the imports defined in the index.d.ts file. | ||
await rename("index.d.cts", "index.d.ts"); | ||
|
||
await writeFile( | ||
"package.json", | ||
JSON.stringify( | ||
{ | ||
name: packageJson.name, | ||
version: process.argv[2] || packageJson.version, | ||
repository: packageJson.repository, | ||
main: "index.cjs", | ||
types: "index.d.ts", | ||
files: ["index.cjs", "index.d.ts"] | ||
}, | ||
undefined, | ||
2 | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "../../../shared/tsconfig.shared.json", | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["src/**/__test__"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
generators/go-v2/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.