From cbf0c34e8f5d4df34007fc5340c98c16539703bc Mon Sep 17 00:00:00 2001 From: Eugene Cheung Date: Fri, 12 Aug 2022 11:11:35 -0400 Subject: [PATCH] feat: support golang (closes #21) --- .gitattributes | 1 - .github/workflows/build.yml | 25 +++++++++++++++++++++++++ .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ .mergify.yml | 2 ++ .projen/tasks.json | 12 ++++++++++++ .projenrc.js | 5 +++++ README.md | 5 +++++ package.json | 4 ++++ 8 files changed, 87 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 099d1c6d..3f7fc0ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,7 +18,6 @@ /.projen/deps.json linguist-generated /.projen/files.json linguist-generated /.projen/tasks.json linguist-generated -/API.md linguist-generated /LICENSE linguist-generated /package.json linguist-generated /tsconfig.dev.json linguist-generated diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a2bd5a1..1f7a235a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -174,3 +174,28 @@ jobs: run: cd .repo && npx projen package:dotnet - name: Collect dotnet Artifact run: mv .repo/dist dist + package-go: + needs: build + runs-on: ubuntu-latest + permissions: {} + if: "! needs.build.outputs.self_mutation_happened" + steps: + - uses: actions/setup-node@v3 + with: + node-version: 14.x + - uses: actions/setup-go@v3 + with: + go-version: ^1.16.0 + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: dist + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Create go artifact + run: cd .repo && npx projen package:go + - name: Collect go Artifact + run: mv .repo/dist dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 13b8d789..0fe9fc4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -195,6 +195,39 @@ jobs: run: npx -p publib@latest publib-nuget env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + release_golang: + name: Publish to GitHub Go Module Repository + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + if: needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@v3 + with: + node-version: 14.x + - uses: actions/setup-go@v3 + with: + go-version: ^1.16.0 + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: dist + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Create go artifact + run: cd .repo && npx projen package:go + - name: Collect go Artifact + run: mv .repo/dist dist + - name: Release + run: npx -p publib@latest publib-golang + env: + GIT_USER_NAME: github-actions + GIT_USER_EMAIL: github-actions@github.com + GITHUB_TOKEN: ${{ secrets.GO_GITHUB_TOKEN }} notify_slack: name: Send Slack notification needs: @@ -204,6 +237,7 @@ jobs: - release_npm - release_nuget - release_pypi + - release_golang runs-on: ubuntu-latest permissions: actions: read diff --git a/.mergify.yml b/.mergify.yml index 03d8326f..0d7d1b5a 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -10,6 +10,7 @@ queue_rules: - status-success=package-java - status-success=package-python - status-success=package-dotnet + - status-success=package-go pull_request_rules: - name: Automatic merge on approval and successful build actions: @@ -29,3 +30,4 @@ pull_request_rules: - status-success=package-java - status-success=package-python - status-success=package-dotnet + - status-success=package-go diff --git a/.projen/tasks.json b/.projen/tasks.json index f3b028ff..2ababbb8 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -154,6 +154,9 @@ }, { "spawn": "package:dotnet" + }, + { + "spawn": "package:go" } ] }, @@ -166,6 +169,15 @@ } ] }, + "package:go": { + "name": "package:go", + "description": "Create go language bindings", + "steps": [ + { + "exec": "jsii-pacmak -v --target go" + } + ] + }, "package:java": { "name": "package:java", "description": "Create java language bindings", diff --git a/.projenrc.js b/.projenrc.js index a2554a98..62f6b1c4 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -36,6 +36,10 @@ const project = new awscdk.AwsCdkConstructLibrary({ mavenArtifactId: "cdkmonitoringconstructs", mavenEndpoint: "https://s01.oss.sonatype.org", }, + // Artifact config: Go + publishToGo: { + moduleName: "github.com/cdklabs/cdkmonitoringconstructs", + }, // Auto approval config autoApproveOptions: { @@ -122,6 +126,7 @@ project.release.addJobs({ "release_npm", "release_nuget", "release_pypi", + "release_golang", ], steps: [ { diff --git a/README.md b/README.md index 912352de..53a3d3d5 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,11 @@ See https://pypi.org/project/cdk-monitoring-constructs/ See https://www.nuget.org/packages/Cdklabs.CdkMonitoringConstructs/ +
Golang + +Coming soon! +
+ ## Features diff --git a/package.json b/package.json index f1e9e8f4..380cae61 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "package": "npx projen package", "package-all": "npx projen package-all", "package:dotnet": "npx projen package:dotnet", + "package:go": "npx projen package:go", "package:java": "npx projen package:java", "package:js": "npx projen package:js", "package:python": "npx projen package:python", @@ -144,6 +145,9 @@ "dotnet": { "namespace": "Cdklabs.CdkMonitoringConstructs", "packageId": "Cdklabs.CdkMonitoringConstructs" + }, + "go": { + "moduleName": "github.com/cdklabs/cdkmonitoringconstructs" } }, "tsc": {