Skip to content

Commit

Permalink
Prepare for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
stack72 committed Oct 18, 2021
1 parent bee5c3c commit 5dc063e
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 6 deletions.
141 changes: 141 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
env:
# THIS GITHUB_TOKEN IS A REQUIREMENT TO BE ABLE TO WRITE TO GH RELEASES
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# IF YOU NEED TO PUBLISH A NPM PACKAGE THEN ENSURE A NPM_TOKEN SECRET IS SET
# AND PUBLISH_NPM: TRUE. IF YOU WANT TO PUBLISH TO A PRIVATE NPM REGISTRY
# THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_NPM: true
NPM_REGISTRY_URL: https://registry.npmjs.org
# IF YOU NEED TO PUBLISH A NUGET PACKAGE THEN ENSURE AN NUGET_PUBLISH_KEY
# SECRET IS SET AND PUBLISH_NUGET: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE
# NPM REGISTRY THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
PUBLISH_NUGET: true
# IF YOU NEED TO PUBLISH A PYPI PACKAGE THEN ENSURE AN PYPI_API_TOKEN
# SECRET IS SET AND PUBLISH_PYPI: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE
# PYPI REGISTRY THEN ENSURE THE PYPI_REPOSITORY_URL IS SET. IF YOU ARE USING AN API_TOKEN THEN
# YOU DO NOT NEED TO CHANGE THE PYPI_USERNAME (__token__) , IF YOU ARE USING PASSWORD AUTHENTICATION THEN YOU WILL
# NEED TO CHANGE TO USE THE CORRECT PASSWORD
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
PYPI_USERNAME: "pulumi"
PYPI_REPOSITORY_URL: ""
PUBLISH_PYPI: true
jobs:
publish_binary:
name: Publish Provider Binary
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Install Pulumi CLI
uses: pulumi/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: us-east-2
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-duration-seconds: 3600
role-external-id: upload-pulumi-release
role-session-name: uploader@githubActions
role-to-assume: ${{ secrets.AWS_UPLOAD_ROLE_ARN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: -f .goreleaser.yml --rm-dist
version: latest
publish_sdk:
name: Publish SDKs
runs-on: ubuntu-latest
needs: publish_binary
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goversion }}
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl
- name: Install Pulumi CLI
uses: pulumi/[email protected]
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: ${{matrix.nodeversion}}
registry-url: ${{env.NPM_REGISTRY_URL}}
- name: Setup DotNet
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{matrix.dotnetverson}}
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: ${{matrix.pythonversion}}
- name: Build SDK
run: make build_${{ matrix.language }}_sdk
- name: Check worktree clean
run: |
git update-index -q --refresh
if ! git diff-files --quiet; then
>&2 echo "error: working tree is not clean, aborting!"
git status
git diff
exit 1
fi
- if: ${{ matrix.language == 'python' && env.PUBLISH_PYPI == 'true' }}
name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ env.PYPI_USERNAME }}
password: ${{ env.PYPI_PASSWORD }}
packages_dir: ${{github.workspace}}/sdk/python/bin/dist
- if: ${{ matrix.language == 'nodejs' && env.PUBLISH_NPM == 'true' }}
uses: JS-DevTools/npm-publish@v1
with:
access: "public"
token: ${{ env.NPM_TOKEN }}
package: ${{github.workspace}}/sdk/nodejs/bin/package.json
- if: ${{ matrix.language == 'dotnet' && env.PUBLISH_NUGET == 'true' }}
name: publish nuget package
run: |
dotnet nuget push ${{github.workspace}}/sdk/dotnet/bin/Debug/*.nupkg -s ${{ env.NUGET_FEED_URL }} -k ${{ env.NUGET_PUBLISH_KEY }}
echo "done publishing packages"
strategy:
fail-fast: true
matrix:
dotnetversion:
- 3.1.301
goversion:
- 1.16.x
language:
- nodejs
- python
- dotnet
- go
nodeversion:
- 14.x
pythonversion:
- "3.9"
name: release
"on":
push:
tags:
- v*.*.*
34 changes: 34 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
archives:
- id: archive
name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}'
before:
hooks:
- make build_provider
blobs:
- bucket: get.pulumi.com
folder: releases/plugins/
ids:
- archive
provider: s3
region: us-west-2
builds:
- binary: pulumi-resource-kubernetes-cert-manager
dir: provider
env:
- CGO_ENABLED=0
goarch:
- amd64
goos:
- darwin
- windows
- linux
ldflags:
- -X github.com/pulumi/pulumi-kubernetes-cert-manager/provider/pkg/version.Version={{.Tag }}
main: ./cmd/pulumi-resource-kubernetes-cert-manager/
changelog:
skip: true
release:
disable: false
prerelease: auto
snapshot:
name_template: '{{ .Tag }}-SNAPSHOT'
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := 0.0.1
VERSION := $(shell pulumictl get version)

PACK := kubernetes-cert-manager
PROJECT := github.com/pulumi/pulumi-${PACK}
Expand All @@ -10,7 +10,7 @@ VERSION_PATH := provider/pkg/version.Version
WORKING_DIR := $(shell pwd)
SCHEMA_PATH := ${WORKING_DIR}/schema.json

default:: generate build install
GOPATH := $(shell go env GOPATH)

generate:: gen_go_sdk gen_dotnet_sdk gen_nodejs_sdk gen_python_sdk

Expand Down Expand Up @@ -43,7 +43,7 @@ gen_dotnet_sdk::
rm -rf sdk/dotnet
cd provider/cmd/${CODEGEN} && go run . dotnet ../../../sdk/dotnet ${SCHEMA_PATH}

build_dotnet_sdk:: DOTNET_VERSION := ${VERSION}
build_dotnet_sdk:: DOTNET_VERSION := $(shell pulumictl get version --language dotnet)
build_dotnet_sdk:: gen_dotnet_sdk
cd sdk/dotnet/ && \
echo "${DOTNET_VERSION}" >version.txt && \
Expand All @@ -60,11 +60,12 @@ install_dotnet_sdk:: build_dotnet_sdk
gen_nodejs_sdk::
rm -rf sdk/nodejs
cd provider/cmd/${CODEGEN} && go run . nodejs ../../../sdk/nodejs ${SCHEMA_PATH}
# HACKHACK: work around https://github.com/pulumi/pulumi/issues/7979:
# HACKHACK: work around https://github.com/pulumi/pulumi/issues/7979:
find sdk/nodejs -name "*.ts" -exec sed -i.bak \
's/pulumiKubernetes\.types\.input\.\([a-zA-Z0-9]*\)\.\([a-zA-Z0-9]*\)\.\([a-zA-Z]*\)Args/pulumiKubernetes.types.input.\1.\2.\3/g' \
'{}' \;

build_nodejs_sdk:: VERSION := $(shell pulumictl get version --language javascript)
build_nodejs_sdk:: gen_nodejs_sdk
cd sdk/nodejs/ && \
yarn install && \
Expand All @@ -75,6 +76,7 @@ build_nodejs_sdk:: gen_nodejs_sdk
rm ./bin/package.json.bak

install_nodejs_sdk:: build_nodejs_sdk
yarn unlink ${PACK} || true
yarn link --cwd ${WORKING_DIR}/sdk/nodejs/bin


Expand All @@ -85,11 +87,14 @@ gen_python_sdk::
cd provider/cmd/${CODEGEN} && go run . python ../../../sdk/python ${SCHEMA_PATH}
cp ${WORKING_DIR}/README.md sdk/python

build_python_sdk:: PYPI_VERSION := ${VERSION}
build_python_sdk:: PYPI_VERSION := $(shell pulumictl get version --language python)
build_python_sdk:: gen_python_sdk
cd sdk/python/ && \
python3 setup.py clean --all 2>/dev/null && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e "s/\$${VERSION}/${PYPI_VERSION}/g" -e "s/\$${PLUGIN_VERSION}/${VERSION}/g" ./bin/setup.py && \
sed -i.bak -e 's/^VERSION = .*/VERSION = "$(PYPI_VERSION)"/g' -e 's/^PLUGIN_VERSION = .*/PLUGIN_VERSION = "$(VERSION)"/g' ./bin/setup.py && \
rm ./bin/setup.py.bak && \
cd ./bin && python3 setup.py build sdist

## Empty build target for Go
build_go_sdk::
5 changes: 5 additions & 0 deletions sdk/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ This component supports all of the configuration options of the [official Helm c
https://github.com/jetstack/cert-manager/tree/master/deploy/charts/cert-manager), except that these
are strongly typed so you will get IDE support and static error checking.

The Helm deployment uses reasonable defaults, including the chart name and repo URL, however,
if you need to override them, you may do so using the `helmOptions` parameter. Refer to
[the API docs for the `kubernetes:helm/v3:Release` Pulumi type](
https://www.pulumi.com/docs/reference/pkg/kubernetes/helm/v3/release/#inputs) for a full set of choices.

For complete details, refer to the Pulumi Package details within the Pulumi Registry.

0 comments on commit 5dc063e

Please sign in to comment.