From 63db0e752b0ce8ed45d480c321c408abc70a614c Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Tue, 27 Feb 2024 12:00:21 +0100 Subject: [PATCH 01/12] Add file with go version --- languages/go/.version | 1 + 1 file changed, 1 insertion(+) create mode 100644 languages/go/.version diff --git a/languages/go/.version b/languages/go/.version new file mode 100644 index 000000000..6c6aa7cb0 --- /dev/null +++ b/languages/go/.version @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file From 7fa4ccb93f08a9695acc89c86a77a27a01dd0c5c Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Tue, 27 Feb 2024 12:00:34 +0100 Subject: [PATCH 02/12] Add go sdk to version bump --- .github/workflows/version-bump.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index e40f68a8e..b705cb9c0 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -19,6 +19,7 @@ on: - cli - napi - python-sdk + - go-sdk version_number: description: "New version (example: '2024.1.0')" required: true @@ -150,6 +151,11 @@ jobs: sed -i 's/version = "[0-9]\.[0-9]\.[0-9]"/version = "${{ inputs.version_number }}"/' ./languages/python/pyproject.toml sed -i 's/__version__ = "[0-9]\.[0-9]\.[0-9]"/__version__ = "${{ inputs.version_number }}"/' ./languages/python/bitwarden_sdk/__init__.py + ### go + - name: Bump go-sdk Version + if: ${{ inputs.project == 'go-sdk' }} + run: sed -i 's/[0-9]\.[0-9]\.[0-9]/${{ inputs.version_number }}/' ./languages/go/.version + ############################ # VERSION BUMP SECTION END # ############################ From 29711bea5ea3a61aa3fd27e8808161abb36c5368 Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Tue, 27 Feb 2024 12:00:41 +0100 Subject: [PATCH 03/12] Add build go pipeline --- .github/workflows/build-go.yaml | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/build-go.yaml diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml new file mode 100644 index 000000000..dd61fef6c --- /dev/null +++ b/.github/workflows/build-go.yaml @@ -0,0 +1,38 @@ +on: + push: + branches: + - main + - rc + - hotfix-rc + + + +jobs: + build: + name: Build + needs: + - build_rust + - generate-schemas + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Setup Go environment + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Cache dependencies + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... From 132d1f78c669856b1f7381a1af195af0228845da Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Tue, 27 Feb 2024 12:00:51 +0100 Subject: [PATCH 04/12] Update release go pipeline --- .github/workflows/golang-release.yml | 73 -------------- .github/workflows/release-go.yml | 146 +++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/golang-release.yml create mode 100644 .github/workflows/release-go.yml diff --git a/.github/workflows/golang-release.yml b/.github/workflows/golang-release.yml deleted file mode 100644 index 10ec7675e..000000000 --- a/.github/workflows/golang-release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Go Release - -on: - workflow_dispatch: - inputs: - version_number: - description: "New Version" - required: true - -env: - GO111MODULE: on - GO_VERSION: "^1.18" - -jobs: - build_rust: - uses: ./.github/workflows/build-rust-cross-platform.yml - - generate-schemas: - uses: ./.github/workflows/generate_schemas.yml - - build: - name: Build - needs: - - build_rust - - generate-schemas - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Setup Go environment - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Cache dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Build - run: go build -v ./... - - - name: Test - run: go test -v ./... - - release: - name: Release - needs: build - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Setup Go environment - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Set release version - run: echo "VERSION=${{ github.event.inputs.version_number }}" >> $GITHUB_ENV - - - name: Install Goreleaser - run: go install github.com/goreleaser/goreleaser@v1.21.2 - - - name: Run Goreleaser - run: goreleaser release --rm-dist --skip-validate - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ env.VERSION }} diff --git a/.github/workflows/release-go.yml b/.github/workflows/release-go.yml new file mode 100644 index 000000000..51a4bd2cb --- /dev/null +++ b/.github/workflows/release-go.yml @@ -0,0 +1,146 @@ +name: Release Go + +on: + workflow_dispatch: + inputs: + version_number: + description: "New Version" + required: true + +env: + GO111MODULE: on + GO_VERSION: "^1.18" + +jobs: + validate: + name: Setup + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Branch check + if: ${{ github.event.inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + echo "===================================" + echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "===================================" + exit 1 + fi + + - name: Get version + id: version + run: | + VERSION=$(cat languages/go/.version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + repo-sync: + name: Push changed files to SDK Go repo + runs-on: ubuntu-22.04 + needs: validate + env: + _KEY_VAULT: "bitwarden-ci" + _BOT_EMAIL: 106330231+bitwarden-devops-bot@users.noreply.github.com + _BOT_NAME: bitwarden-devops-bot + _PKG_VERSION: ${{ needs.validate.outputs.version }} + steps: + - name: Checkout SDK repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + path: sdk + + - name: Checkout SDK-Go repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + repository: bitwarden/sdk-go + path: sdk-go + ref: main + + - name: Login to Azure - Prod Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@62d1bf7c3e31c458cc7236b1e69a475d235cd78f + with: + keyvault: ${{ env._KEY_VAULT }} + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Setup Git + working-directory: sdk-go + run: | + git config --local user.email "${{ env._BOT_EMAIL }}" + git config --local user.name "${{ env._BOT_NAME }}" + + - name: Update files + run: | + # Copy files to local sdk-go repo path + cp --verbose -rf sdk/languages/go sdk-go + + - name: Push changes + working-directory: sdk-go + run: | + git add . + git commit -m "Update Go SDK to ${{ github.sha }}" + + if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then + echo "===================================" + echo "[!] Dry Run - Skipping push" + echo "===================================" + git ls-files -m + exit 0 + else + git push origin main + fi + + - name: Create release tag on SDK Go repo + if: ${{ github.event.inputs.release_type != 'Dry Run' }} + working-directory: sdk-go + run: | + # Check if tag exists, set output then exit 0 if true. + if git log v${{ env._PKG_VERSION }} >/dev/null 2>&1; then + echo "===================================" + echo "[!] Tag v${{ env._PKG_VERSION }} already exists" + echo "===================================" + exit 1 + fi + + git tag v${{ env._PKG_VERSION }} + git push origin v${{ env._PKG_VERSION }} + + github-release: + name: GitHub Release + runs-on: ubuntu-22.04 + needs: + - repo-sync + - validate + env: + _PKG_VERSION: ${{ needs.validate.outputs.version }} + steps: + - name: Login to Azure - Prod Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@62d1bf7c3e31c458cc7236b1e69a475d235cd78f + with: + keyvault: ${{ env._KEY_VAULT }} + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Create release + if: ${{ github.event.inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0 + with: + tag: v${{ env._PKG_VERSION }} + name: v${{ env._PKG_VERSION }} + body: "" + token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} + draft: true + repo: bitwarden/sdk-go From 45307792f82fce4dd527e66a4c94b28302137904 Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Tue, 27 Feb 2024 12:05:45 +0100 Subject: [PATCH 05/12] Add pr trigger to build go --- .github/workflows/build-go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index dd61fef6c..5cf73f0d6 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -5,7 +5,7 @@ on: - rc - hotfix-rc - + pull_request: jobs: build: From 6a51438e24709e920333fbe9c662a787df79d62f Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Tue, 27 Feb 2024 18:12:14 +0100 Subject: [PATCH 06/12] Changed name for repo --- .github/workflows/release-go.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-go.yml b/.github/workflows/release-go.yml index 51a4bd2cb..cb1208a78 100644 --- a/.github/workflows/release-go.yml +++ b/.github/workflows/release-go.yml @@ -55,8 +55,8 @@ jobs: - name: Checkout SDK-Go repo uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 with: - repository: bitwarden/sdk-go - path: sdk-go + repository: bitwarden/sm-sdk-go + path: sm-sdk-go ref: main - name: Login to Azure - Prod Subscription @@ -72,18 +72,18 @@ jobs: secrets: "github-pat-bitwarden-devops-bot-repo-scope" - name: Setup Git - working-directory: sdk-go + working-directory: sm-sdk-go run: | git config --local user.email "${{ env._BOT_EMAIL }}" git config --local user.name "${{ env._BOT_NAME }}" - name: Update files run: | - # Copy files to local sdk-go repo path - cp --verbose -rf sdk/languages/go sdk-go + # Copy files to local sm-sdk-go repo path + cp --verbose -rf sdk/languages/go sm-sdk-go - name: Push changes - working-directory: sdk-go + working-directory: sm-sdk-go run: | git add . git commit -m "Update Go SDK to ${{ github.sha }}" @@ -100,7 +100,7 @@ jobs: - name: Create release tag on SDK Go repo if: ${{ github.event.inputs.release_type != 'Dry Run' }} - working-directory: sdk-go + working-directory: sm-sdk-go run: | # Check if tag exists, set output then exit 0 if true. if git log v${{ env._PKG_VERSION }} >/dev/null 2>&1; then @@ -143,4 +143,4 @@ jobs: body: "" token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} draft: true - repo: bitwarden/sdk-go + repo: bitwarden/sm-sdk-go From 5dba2195c27f9f2085012c604448098ebe6cb762 Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Wed, 28 Feb 2024 11:21:20 +0100 Subject: [PATCH 07/12] FIx buildgo --- .github/workflows/build-go.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index 5cf73f0d6..29b0ad611 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -7,12 +7,13 @@ on: pull_request: +env: + GO111MODULE: on + GO_VERSION: "^1.18" + jobs: build: name: Build - needs: - - build_rust - - generate-schemas runs-on: ubuntu-22.04 steps: - name: Checkout Repository From 0d10798293ce5363f7c9baa9217621f47f4c4e15 Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Wed, 28 Feb 2024 11:21:30 +0100 Subject: [PATCH 08/12] Replace version input --- .github/workflows/release-go.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-go.yml b/.github/workflows/release-go.yml index cb1208a78..830e5f313 100644 --- a/.github/workflows/release-go.yml +++ b/.github/workflows/release-go.yml @@ -3,9 +3,14 @@ name: Release Go on: workflow_dispatch: inputs: - version_number: - description: "New Version" + release_type: + description: "Release Options" required: true + default: "Release" + type: choice + options: + - Release + - Dry Run env: GO111MODULE: on From 6938c17d296555ceb14539f456fa4f6912347d65 Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Wed, 28 Feb 2024 17:34:59 +0100 Subject: [PATCH 09/12] Use path --- .github/workflows/build-go.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index 29b0ad611..69774b0fb 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -33,7 +33,9 @@ jobs: ${{ runner.os }}-go- - name: Build + working-directory: languages/go run: go build -v ./... - name: Test + working-directory: languages/go run: go test -v ./... From e2ca445f6ed6f380b70ba4853b4b343f82682a41 Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Wed, 28 Feb 2024 17:37:41 +0100 Subject: [PATCH 10/12] Add name to build go --- .github/workflows/build-go.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index 69774b0fb..a4a0b37fb 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -1,3 +1,5 @@ +name: Build Go SDK + on: push: branches: From 9a59559305a9c26a15c8358ac9adfb1d65746aa0 Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Wed, 28 Feb 2024 17:50:47 +0100 Subject: [PATCH 11/12] Fix --- .github/workflows/build-go.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index a4a0b37fb..31aee3f9b 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -34,6 +34,9 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: Generate schemas + run: npm run schemas + - name: Build working-directory: languages/go run: go build -v ./... From 78ead6c81edb97770b6750fd68c8f0af0fbd1c6d Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Wed, 28 Feb 2024 17:52:15 +0100 Subject: [PATCH 12/12] RUn npm ci --- .github/workflows/build-go.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index 31aee3f9b..433013aac 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -34,6 +34,9 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: npm ci + run: npm ci + - name: Generate schemas run: npm run schemas