From ce235728456511ae37fae690c0261198f55916a5 Mon Sep 17 00:00:00 2001 From: Jonne Date: Fri, 18 Dec 2020 10:14:35 +0100 Subject: [PATCH] Create release (#2) * Update readme * Add release github action --- .github/workflows/release.yml | 267 ++++++++++++++++++++++++++++++++++ .goreleaser.yaml | 27 ++++ README.md | 83 ++++------- 3 files changed, 326 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..092f561 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,267 @@ +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GO111MODULE: "on" + PROVIDER: commercetools + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TRAVIS_OS_NAME: linux +jobs: + build_sdk: + name: build_sdk + needs: prerequisites + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Checkout Scripts Repo + uses: actions/checkout@v2 + with: + path: ci-scripts + repository: pulumi/scripts + - name: Unshallow clone for tags + run: git fetch --prune --unshallow --tags + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Install pulumictl + uses: jaxxstorm/action-install-gh-release@v1.1.0 + with: + repo: pulumi/pulumictl + - name: Install Pulumi CLI + uses: pulumi/action-install-pulumi-cli@v1.0.1 + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: ${{matrix.nodeversion}} + registry-url: https://registry.npmjs.org + - name: Setup DotNet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{matrix.dotnetverson}} + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{matrix.pythonversion}} + - name: Download provider + tfgen binaries + uses: actions/download-artifact@v2 + with: + name: ${{ env.PROVIDER }}-provider.tar.gz + path: ${{ github.workspace }}/bin + - name: Untar provider binaries + run: tar -zxf ${{ github.workspace }}/bin/provider.tar.gz -C ${{ github.workspace + }}/bin + - name: Restore binary perms + run: find ${{ github.workspace }} -name "pulumi-*-${{ env.PROVIDER }}" -print + -exec chmod +x {} \; + - name: Build SDK + run: make build_${{ matrix.language }} + - name: Check worktree clean + run: ./ci-scripts/ci/check-worktree-is-clean + - name: Compress SDK folder + run: tar -zcf sdk/${{ matrix.language }}.tar.gz -C sdk/${{ matrix.language }} + . + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.language }}-sdk.tar.gz + path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz + strategy: + fail-fast: true + matrix: + dotnetversion: + - 3.1.301 + goversion: + - 1.15.x + language: + - nodejs + - python + - dotnet + - go + nodeversion: + - 13.x + pythonversion: + - "3.7" + prerequisites: + name: prerequisites + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Checkout Scripts Repo + uses: actions/checkout@v2 + with: + path: ci-scripts + repository: pulumi/scripts + - name: Unshallow clone for tags + run: git fetch --prune --unshallow --tags + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Install pulumictl + uses: jaxxstorm/action-install-gh-release@v1.1.0 + with: + repo: pulumi/pulumictl + - name: Install Pulumi CLI + uses: pulumi/action-install-pulumi-cli@v1.0.1 + - name: Build tfgen & provider binaries + run: sudo make provider + - name: Tar provider binaries + run: sudo tar -zcf ${{ github.workspace }}/bin/provider.tar.gz -C ${{ github.workspace + }}/bin/ pulumi-resource-${{ env.PROVIDER }} pulumi-tfgen-${{ env.PROVIDER + }} + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PROVIDER }}-provider.tar.gz + path: ${{ github.workspace }}/bin/provider.tar.gz + strategy: + fail-fast: true + lint: + container: golangci/golangci-lint:latest + name: lint + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Checkout Scripts Repo + uses: actions/checkout@v2 + with: + path: ci-scripts + repository: pulumi/scripts + - name: Unshallow clone for tags + run: git fetch --prune --unshallow --tags + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Install pulumictl + uses: jaxxstorm/action-install-gh-release@v1.1.0 + with: + repo: pulumi/pulumictl + - name: Install Pulumi CLI + uses: pulumi/action-install-pulumi-cli@v1.0.1 + - name: Run golangci + run: make lint_provider + strategy: + fail-fast: true + lint_sdk: + container: golangci/golangci-lint:latest + name: lint-sdk + needs: build_sdk + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Checkout Scripts Repo + uses: actions/checkout@v2 + with: + path: ci-scripts + repository: pulumi/scripts + - name: Unshallow clone for tags + run: git fetch --prune --unshallow --tags + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Install pulumictl + uses: jaxxstorm/action-install-gh-release@v1.1.0 + with: + repo: pulumi/pulumictl + - name: Install Pulumi CLI + uses: pulumi/action-install-pulumi-cli@v1.0.1 + - name: Run golangci + run: cd sdk/go/commercetools && golangci-lint run -c ../../../.golangci.yml + strategy: + fail-fast: true + publish: + needs: build_sdk + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Checkout Scripts Repo + uses: actions/checkout@v2 + with: + path: ci-scripts + repository: pulumi/scripts + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + args: -p 4 release --rm-dist + version: latest + publish_sdk: + name: publish_sdk + needs: publish + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Checkout Scripts Repo + uses: actions/checkout@v2 + with: + path: ci-scripts + repository: pulumi/scripts + - name: Unshallow clone for tags + run: git fetch --prune --unshallow --tags + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Install pulumictl + uses: jaxxstorm/action-install-gh-release@v1.1.0 + with: + repo: pulumi/pulumictl + - name: Install Pulumi CLI + uses: pulumi/action-install-pulumi-cli@v1.0.1 + - name: Setup Node + uses: actions/setup-node@v1 + with: + always-auth: true + registry-url: https://registry.npmjs.org + - name: Setup DotNet + uses: actions/setup-dotnet@v1 + - name: Setup Python + uses: actions/setup-python@v2 + - name: Download Python SDK + uses: actions/download-artifact@v2 + with: + name: python-sdk.tar.gz + path: ${{ github.workspace}}/sdk + - name: Unzip Python SDK + run: tar -zxf ${{ github.workspace}}/sdk/python.tar.gz -C ${{ github.workspace}}/sdk/python + - name: Install Twine + run: python -m pip install pip twine + - name: Download NodeJS SDK + uses: actions/download-artifact@v2 + with: + name: nodejs-sdk.tar.gz + path: ${{ github.workspace}}/sdk + - name: Unzip NodeJS SDK + run: tar -zxf ${{ github.workspace}}/sdk/nodejs.tar.gz -C ${{ github.workspace}}/sdk/nodejs + - name: Download DotNet SDK + uses: actions/download-artifact@v2 + with: + name: dotnet-sdk.tar.gz + path: ${{ github.workspace}}/sdk + - name: Unzip DotNet SDK + run: tar -zxf ${{ github.workspace}}/sdk/dotnet.tar.gz -C ${{ github.workspace}}/sdk/dotnet + - env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + name: Publish SDKs + run: ./ci-scripts/ci/publish-tfgen-package ${{ github.workspace }} + strategy: + fail-fast: true +name: release +"on": + push: + tags: + - v*.*.* \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..fde9b99 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,27 @@ +archives: +- id: archive + name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}' +before: + hooks: + - make tfgen +builds: +- binary: pulumi-resource-commercetools + dir: provider + env: + - CGO_ENABLED=0 + - GO111MODULE=on + goarch: + - amd64 + goos: + - darwin + - windows + - linux + ldflags: + - -X github.com/unplatform-io/pulumi-commercetools/provider/v3/pkg/version.Version={{.Tag}} + main: ./cmd/pulumi-resource-commercetools/ +changelog: + skip: true +release: + disable: false +snapshot: + name_template: '{{ .Tag }}-SNAPSHOT' \ No newline at end of file diff --git a/README.md b/README.md index b5287ca..ff14b02 100644 --- a/README.md +++ b/README.md @@ -1,86 +1,67 @@ -# Terraform Bridge Provider Boilerplate +[![Actions Status](https://github.com/unplatform-io/pulumi-commercetools/workflows/master/badge.svg)](https://github.com/unplatform-io/pulumi-commercetools/actions) +[![NPM version](https://badge.fury.io/js/%40unplatform%2Fcommercetools.svg)](https://www.npmjs.com/package/@unplatform/commercetools) +[![Python version](https://badge.fury.io/py/pulumi-commercetools.svg)](https://pypi.org/project/pulumi-commercetools) +[![NuGet version](https://badge.fury.io/nu/pulumi.commercetools.svg)](https://badge.fury.io/nu/pulumi.commercetools) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/unplatform-io/pulumi-commercetools/sdk/v2/go)](https://pkg.go.dev/github.com/unplatform-io/pulumi-commercetools/sdk/v2/go) -This repository contains boilerplate code for building a new Pulumi provider which wraps an existing -Terraform provider, if the existing provider uses _Go Modules_. +# CommerceTools provider +The CommerceTools resource provider for Pulumi lets you provision [CommerceTools](https://commercetools.com/) resources. -Modify this README to describe: +This provider is a [bridge] (https://github.com/pulumi/pulumi-terraform-bridge) to the excellent [CommerceTools Terraform Provider](https://github.com/labd/terraform-provider-commercetools) from the Labd folks. -- The type of resources the provider manages -- Add a build status image from Travis at the top of the README -- Update package names in the information below -- Add any important documentation of concepts (e.g. the "serverless" components in the AWS provider). +To use this package, please [install the Pulumi CLI first](https://pulumi.io/).] -## Creating a Pulumi Terraform Bridge Provider - -First, clone this repo with the name of the desired provider in place of `commercetools`: - -``` -git clone https://github.com/pulumi/pulumi-tf-provider-boilerplate pulumi-commercetools -``` - -Second, replace references to `commercetools` with the name of your provider: - -``` -make prepare NAME=foo REPOSITORY=github.com/pulumi/pulumi-foo -``` - -Next, list the configuration points for the provider in the area of the README. - - -> Note: If the name of the desired Pulumi provider differs from the name of the Terraform provider, you will need to carefully distinguish between the references - see https://github.com/pulumi/pulumi-azure for an example. - -### Add dependencies - -In order to properly build the sdks, the following tools are expected: -- `pulumictl` (See the project's README for installation instructions: https://github.com/pulumi/pulumictl) - -In the root of the repository, run: - -- `GO111MODULE=on go get github.com/pulumi/pulumi-terraform@master` -- `(cd provider && go get github.com/terraform-providers/terraform-provider-foo)` (where `foo` is the name of the provider - note the parenthesis to run this in a subshell) -- `(cd provider && go mod download)` +## Installing -### Build the provider: +The plugin itself needs to be installed by running: -- Edit `provider/resources.go` to map each resource, and specify provider information -- `make build_sdks` + `pulumi plugin install --server https://github.com/unplatform-io/pulumi-commercetools/releases/download/v0.0.0 resource commercetools v0.0.0` -## Installing +Where v0.0.0 is the desired version. -This package is available in many languages in the standard packaging formats. +This SDK is available in many languages in the standard packaging formats. ### Node.js (Java/TypeScript) To use from JavaScript or TypeScript in Node.js, install using either `npm`: - $ npm install @pulumi/xyx + $ npm install @unplatform/commercetools or `yarn`: - $ yarn add @pulumi/xyx + $ yarn add @unplatform/commercetools ### Python To use from Python, install using `pip`: - $ pip install pulumi_xyx + $ pip install pulumi_commercetools ### Go To use from Go, use `go get` to grab the latest version of the library - $ go get github.com/pulumi/pulumi-commercetools/sdk/go/... + $ go get github.com/unplatform-io/pulumi-commercetools/sdk/v2/go/... + +### .NET + +To use from .NET, install using `dotnet add package`: + + $ dotnet add package Pulumi.CommerceTools ## Configuration The following configuration points are available for the `commercetools` provider: -- `commercetools:apiKey` (environment: `XYZ_API_KEY`) - the API key for `commercetools` -- `commercetools:region` (environment: `XYZ_REGION`) - the region in which to deploy resources +- `commercetools:apiUrl` - the url of the commercetools api (e.g. `https://api.europe-west1.gcp.commercetools.com`) +- `commercetools:tokenUrl` - the url used to authenticate (e.g. `https://auth.europe-west1.gcp.commercetools.com`) +- `commercetools:scopes` - the authentication scopes needed +- `commercetools:clientId` - the client id used to authenticate +- `commercetools:clientSecret` - the client secret used to authenticate +- `commercetools:projectKey` - the key of the commerce tools project ## Reference -For detailed reference documentation, please visit [the API docs][1]. - +For detailed reference documentation, please visit [the docs of the commerce tools terraform provider][1]. -[1]: https://www.pulumi.com/docs/reference/pkg/x/ +[1]: https://commercetools-terraform-provider.readthedocs.io/en/latest/