Skip to content

Commit

Permalink
Initial build
Browse files Browse the repository at this point in the history
  • Loading branch information
cleverguy25 committed Jun 3, 2024
1 parent 59b15f9 commit 64ad63a
Show file tree
Hide file tree
Showing 15 changed files with 504 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/actions/generate_sdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Generate SDKs
description: Generate SDKs using the openapi-generator-cli

runs:
using: "composite"
steps:
- name: Install OpenAPI Generator CLI
run: npm install @openapitools/openapi-generator-cli -g
shell: bash

- name: Generate SDKs
run: |
# Generate the SDKs
make generate_go_client_sdk generate_ts_client_sdk
shell: bash
10 changes: 10 additions & 0 deletions .github/scripts/calculate-npm-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
if [[ ! "$1" =~ "-" ]]; then
echo "latest"
elif [[ "$1" =~ "-beta" ]]; then
echo "beta"
elif [[ "$1" =~ "-rc" ]]; then
echo "rc"
else
echo "dev"
fi
13 changes: 13 additions & 0 deletions .github/scripts/get-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -euo pipefail

ROOT=$(dirname "${0}")/../..

if [ -n "${CI:-""}" ]; then
>&2 echo "::group::Get version"
trap ">&2 echo '::endgroup::'" EXIT # bash equivalent of defer func()
fi

# Remove whitespace, this is our version:
tr -d '[:space:]' < "${ROOT}/.version"
16 changes: 16 additions & 0 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Run Acceptance Tests from PR

on:
pull_request:
paths-ignore:
- 'CHANGELOG.md'
- 'CHANGELOG_PENDING.md'

jobs:
lint:
uses: ./.github/workflows/stage-lint.yml
test:
uses: ./.github/workflows/stage-test.yml
with:
enable-coverage: true
secrets: inherit
26 changes: 26 additions & 0 deletions .github/workflows/publish-prerelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish Prerelease

on:
push:
tags:
- v*.*.*-**

env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}

jobs:
# lint:
# uses: ./.github/workflows/stage-lint.yml
# test:
# uses: ./.github/workflows/stage-test.yml
# with:
# enable-coverage: true
# secrets: inherit

publish-sdks:
# needs: [test, lint]
uses: ./.github/workflows/stage-publish-sdk.yml
with:
version: ${{ github.ref_name }}
prerelease: true
secrets: inherit
29 changes: 29 additions & 0 deletions .github/workflows/publish-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish Release

on:
push:
tags:
- v*.*.*
- '!v*.*.*-**'

env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}

jobs:
lint:
uses: ./.github/workflows/stage-lint.yml

test:
uses: ./.github/workflows/stage-test.yml
with:
enable-coverage: true
secrets: inherit

publish-sdks:
# needs: [test, lint]
uses: ./.github/workflows/stage-publish-sdk.yml
with:
version: ${{ github.ref_name }}
prerelease: false
secrets: inherit

28 changes: 28 additions & 0 deletions .github/workflows/publish-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish Snapshot

on:
push:
branches: ['main', 'feature/**', 'feature-**']
paths-ignore:
- 'CHANGELOG.md'
- 'CHANGELOG_PENDING.md'
- 'README.md'

env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}

jobs:
lint:
uses: ./.github/workflows/stage-lint.yml
test:
uses: ./.github/workflows/stage-test.yml
with:
enable-coverage: true
secrets: inherit
publish-sdks:
# needs: [test, lint]
uses: ./.github/workflows/stage-publish-sdk.yml
with:
version: ${{ github.ref_name }}
prerelease: true
secrets: inherit
69 changes: 69 additions & 0 deletions .github/workflows/stage-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Lint

on:
workflow_call:

permissions: read-all

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
lint_go:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Set up Go 1.20
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- run: go mod tidy
- name: Fail if go mod not tidy
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error go.mod not tidy"
exit 1
fi
# We leverage the golangci-lint action to install
# and maintain the cache,
# but we want to run the command ourselves.
# The action doesn't have an install-only mode,
# so we'll ask it to print its version only.
- name: Install golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
args: --version

- name: Lint
run: make lint-golang
check-copyright:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Set up Go 1.20
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Lint
run: make lint-copyright
check-sdk-generation-clean:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Generate SDKs
uses: ./.github/actions/generate_sdk

- name: Check worktree clean
uses: pulumi/git-status-check-action@v1

- run: git status --porcelain
shell: bash
127 changes: 127 additions & 0 deletions .github/workflows/stage-publish-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Publish-SDK

on:
workflow_call:
inputs:
version:
required: true
type: string
description: Version to be used to publish the SDKs
prerelease:
required: true
type: boolean
description: Indicates if we're doing a pre- or proper release.

env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

jobs:

publish-nodejs-sdk:
runs-on: ubuntu-latest
name: publish-nodejs-sdk
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org

- name: Generate SDKs
uses: ./.github/actions/generate_sdk
env:
VERSION: ${{ inputs.version }}

- name: Calculate tag
id: tag
run: echo "tag=$(./.github/scripts/calculate-npm-tag.sh "${{ inputs.version }}")" >> "$GITHUB_OUTPUT"

- name: Build Node.JS SDK
working-directory: sdk/typescript
run: |-
npm i
npm run build
cp ../../README.md ../../LICENSE package.json package-lock.json bin/
sed -i.bak -e "s/\${VERSION}/$VERSION/g" ./bin/package.json
rm -rf ./bin/tests/*
env:
VERSION: ${{ inputs.version }}

- name: Publish Node.JS SDK
working-directory: sdk/typescript/bin
run: npm publish --tag "${{ steps.tag.outputs.tag }}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-go-sdk:
runs-on: ubuntu-latest
name: publish-go-sdk
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org

- name: Generate SDKs
uses: ./.github/actions/generate_sdk
env:
VERSION: ${{ inputs.version }}

- name: Checkout Go SDK repo
uses: actions/checkout@v4
with:
token: ${{ secrets.PULUMI_BOT_TOKEN }}
repository: pulumi/esc-sdk
path: sdk/esc-sdk
fetch-depth: 0

- name: Checkout prerelease branch
if: inputs.prerelease == true
working-directory: sdk/esc-sdk
run: git checkout -b ${{ inputs.version }}

- name: Checkout main branch
if: inputs.prerelease == false
working-directory: sdk/esc-sdk
run: git checkout main

- name: Copy files
uses: pulumi/glob-action@v1
with:
operation: copy
source: sdk/go
destination: sdk/esc-sdk
files: |
**
- name: Commit and tag
working-directory: sdk/esc-sdk
run: |
git config user.name "Pulumi Bot"
git config user.email "[email protected]"
git add .
git commit -m "v${{ inputs.version }}"
git tag "${{ inputs.version }}"
- name: Publish to prerelease branch
if: inputs.prerelease == true
working-directory: sdk/esc-sdk
run: git push -u origin ${{ inputs.version }} --tags

- name: Publish to master branch
if: inputs.prerelease == false
working-directory: sdk/esc-sdk
run: git push -u origin main --tags
Loading

0 comments on commit 64ad63a

Please sign in to comment.