Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,40 @@ jobs:
ref: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}
token: ${{ steps.app-token.outputs.token }}

# Go modules require the module path and all import statements to
# include the major version (e.g. /v7). release-please doesn't handle
# this, so when a release PR bumps the major version we automatically
# rewrite go.mod, imports, and READMEs on the release PR branch.
- name: Migrate Go module path for major version bump
if: steps.release.outputs.pr
run: |
CURRENT_MAJOR=$(grep -oP 'module github\.com/workos/workos-go/v\K[0-9]+' go.mod)
NEW_VERSION=$(jq -r '."."' .release-please-manifest.json)
NEW_MAJOR="${NEW_VERSION%%.*}"

if [ "$CURRENT_MAJOR" = "$NEW_MAJOR" ]; then
echo "No major version change ($CURRENT_MAJOR → $NEW_MAJOR), skipping"
exit 0
fi

echo "Major version bump detected: v$CURRENT_MAJOR → v$NEW_MAJOR"

sed -i "s|module github.com/workos/workos-go/v${CURRENT_MAJOR}|module github.com/workos/workos-go/v${NEW_MAJOR}|" go.mod
find . -name '*.go' -not -path './.git/*' -type f \
-exec sed -i "s|github.com/workos/workos-go/v${CURRENT_MAJOR}|github.com/workos/workos-go/v${NEW_MAJOR}|g" {} +
find . -name 'README.md' -not -path './.git/*' -type f \
-exec sed -i "s|workos-go/v${CURRENT_MAJOR}|workos-go/v${NEW_MAJOR}|g" {} +

git config user.name "workos-sdk-automation[bot]"
git config user.email "255426317+workos-sdk-automation[bot]@users.noreply.github.com"
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: update go.mod and import paths for v${NEW_MAJOR}"
git push
fi
Comment on lines +47 to +75
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Silent no-op risk when grep returns empty

The CURRENT_MAJOR extraction on line 50 uses grep -oP with no fallback. If the regex matches nothing (e.g., the module path ever lacks a /vN suffix, or go.mod is temporarily in a state the pattern doesn't cover), CURRENT_MAJOR is silently set to an empty string. The comparison [ "" = "$NEW_MAJOR" ] then evaluates to false, so the sed commands run with v${CURRENT_MAJOR} expanding to just v — they match nothing, no files change, git diff --staged --quiet passes, and the step exits 0 reporting "No changes to commit" without the migration having run.

Adding set -euo pipefail at the top of the script would cause the step to fail loudly instead, and an explicit guard (if [ -z "$CURRENT_MAJOR" ]; then echo "::error::..."; exit 1; fi) would make the failure mode even clearer. This code is identical to what was present before the reorder, so it's a pre-existing gap — but now that this is the first step to commit, a silent skip here is harder to detect in the PR.


# Inline pending changelog fragments under the version heading
# release-please just wrote in CHANGELOG.md. For PRs that have a
# fragment (the autogen flow always writes one), drop the line
Expand Down Expand Up @@ -129,40 +163,6 @@ jobs:
git commit -m "chore: inline release notes from .changelog-pending"
git push

# Go modules require the module path and all import statements to
# include the major version (e.g. /v7). release-please doesn't handle
# this, so when a release PR bumps the major version we automatically
# rewrite go.mod, imports, and READMEs on the release PR branch.
- name: Migrate Go module path for major version bump
if: steps.release.outputs.pr
run: |
CURRENT_MAJOR=$(grep -oP 'module github\.com/workos/workos-go/v\K[0-9]+' go.mod)
NEW_VERSION=$(jq -r '."."' .release-please-manifest.json)
NEW_MAJOR="${NEW_VERSION%%.*}"

if [ "$CURRENT_MAJOR" = "$NEW_MAJOR" ]; then
echo "No major version change ($CURRENT_MAJOR → $NEW_MAJOR), skipping"
exit 0
fi

echo "Major version bump detected: v$CURRENT_MAJOR → v$NEW_MAJOR"

sed -i "s|module github.com/workos/workos-go/v${CURRENT_MAJOR}|module github.com/workos/workos-go/v${NEW_MAJOR}|" go.mod
find . -name '*.go' -not -path './.git/*' -type f \
-exec sed -i "s|github.com/workos/workos-go/v${CURRENT_MAJOR}|github.com/workos/workos-go/v${NEW_MAJOR}|g" {} +
find . -name 'README.md' -not -path './.git/*' -type f \
-exec sed -i "s|workos-go/v${CURRENT_MAJOR}|workos-go/v${NEW_MAJOR}|g" {} +

git config user.name "workos-sdk-automation[bot]"
git config user.email "255426317+workos-sdk-automation[bot]@users.noreply.github.com"
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: update go.mod and import paths for v${NEW_MAJOR}"
git push
fi

# Detect when a release-please release PR has merged, then tag and
# create the GitHub Release whose body is extracted from CHANGELOG.md
# (now rich, after the inline step above). Runs on every push to main;
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# WorkOS Go Library

[![Go Reference](https://pkg.go.dev/badge/github.com/workos/workos-go/v8.svg)](https://pkg.go.dev/github.com/workos/workos-go/v8)
[![Go Reference](https://pkg.go.dev/badge/github.com/workos/workos-go/v9.svg)](https://pkg.go.dev/github.com/workos/workos-go/v9)

The WorkOS Go library provides a flat, root-level `workos` package for applications written in Go.

Expand All @@ -11,7 +11,7 @@ The WorkOS Go library provides a flat, root-level `workos` package for applicati
Requires Go `1.23+`.

```bash
go get github.com/workos/workos-go/v8
go get github.com/workos/workos-go/v9
```

## Usage
Expand All @@ -23,7 +23,7 @@ import (
"context"
"log"

"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func main() {
Expand Down Expand Up @@ -210,5 +210,5 @@ This SDK is a Go library that uses a flat package layout at the module root rath
Import the root package:

```go
import "github.com/workos/workos-go/v8"
import "github.com/workos/workos-go/v9"
```
2 changes: 1 addition & 1 deletion actions_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

const testActionSecret = "action_secret_key"
Expand Down
2 changes: 1 addition & 1 deletion admin_portal_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api_keys_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion audit_logs_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion authkit_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestGetAuthKitAuthorizationURL_BuildsCorrectURL(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion authorization_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestClient_UserAgentIncludesVersion(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion connect_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion directory_sync_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion events_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"log"

"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func ExampleNewClient() {
Expand Down
2 changes: 1 addition & 1 deletion feature_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @oagen-ignore-file

module github.com/workos/workos-go/v8
module github.com/workos/workos-go/v9

go 1.23

Expand Down
2 changes: 1 addition & 1 deletion groups_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion helpers_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jwks_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestGetJWKSURL_BuildsCorrectURL(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion multi_factor_auth_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion organization_domains_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion organization_membership_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion organizations_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestIterator_MultiPage(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion passwordless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestPasswordless_CreateSession(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pipes_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestGenerateCodeVerifier_DefaultLength(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion public_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestNewPublicClient_CreatesClient(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion radar_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion session_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

const testCookiePassword = "test-cookie-password-for-session-helpers"
Expand Down
2 changes: 1 addition & 1 deletion session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestSealData_UnsealData_RoundTrip(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion sso_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/workos/workos-go/v8"
"github.com/workos/workos-go/v9"
)

func TestGetSSOAuthorizationURL_BuildsCorrectURL(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion sso_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion user_management_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading