diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f38bfe56..582ca8f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,43 +1,70 @@ name: Release on: - # Support manually pushing a new release - workflow_dispatch: {} - # Trigger when a release is published - release: - types: [released] + pull_request: + types: [closed] + branches: [main] defaults: run: shell: bash jobs: - test: - name: Publish to RubyGems + create-release: + name: Create GitHub Release + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump') runs-on: ubuntu-latest + permissions: + contents: write steps: - - uses: actions/checkout@v6 - - uses: ruby/setup-ruby@v1 + - name: Generate token + id: generate-token + uses: actions/create-github-app-token@v1 with: - ruby-version: '3.2' - bundler-cache: true + app-id: ${{ vars.SDK_BOT_APP_ID }} + private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }} - - name: Spec - run: | - bundle exec rspec + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ steps.generate-token.outputs.token }} - - name: Publish - env: - RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + - name: Get version from version.rb + id: get-version run: | - mkdir -p ~/.gem + VERSION=$(grep "VERSION = " lib/workos/version.rb | sed "s/.*VERSION = '\(.*\)'/\1/") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.get-version.outputs.version }} + name: v${{ steps.get-version.outputs.version }} + generate_release_notes: true + token: ${{ steps.generate-token.outputs.token }} + + publish: + name: Publish to RubyGems + needs: create-release + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.2" + bundler-cache: true - cat << EOF > ~/.gem/credentials - --- - :rubygems_api_key: ${RUBYGEMS_API_KEY} - EOF + - name: Run tests + run: bundle exec rspec - chmod 0600 ~/.gem/credentials + - name: Build gem + run: gem build workos.gemspec - bundle exec gem build workos --output=release.gem - bundle exec gem push release.gem + - name: Publish to RubyGems + uses: rubygems/release-gem@v1 diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 00000000..4793399f --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,80 @@ +name: Version Bump + +on: + workflow_dispatch: + inputs: + bump_type: + description: "Version bump type" + required: true + type: choice + options: + - patch + - minor + - major + +jobs: + bump-version: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Generate token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.SDK_BOT_APP_ID }} + private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }} + + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ steps.generate-token.outputs.token }} + + - name: Configure Git + run: | + git config user.name "workos-bot[bot]" + git config user.email "workos-bot[bot]@users.noreply.github.com" + + - name: Read current version + id: current-version + run: | + CURRENT_VERSION=$(grep "VERSION = " lib/workos/version.rb | sed "s/.*VERSION = '\(.*\)'/\1/") + echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + + - name: Bump version + id: bump-version + run: | + CURRENT_VERSION="${{ steps.current-version.outputs.version }}" + IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" + + case "${{ github.event.inputs.bump_type }}" in + major) + NEW_VERSION="$((MAJOR + 1)).0.0" + ;; + minor) + NEW_VERSION="$MAJOR.$((MINOR + 1)).0" + ;; + patch) + NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" + ;; + esac + + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + + - name: Update version in version.rb + run: | + sed -i "s/VERSION = '.*'/VERSION = '${{ steps.bump-version.outputs.new_version }}'/" lib/workos/version.rb + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.generate-token.outputs.token }} + commit-message: "v${{ steps.bump-version.outputs.new_version }}" + title: "v${{ steps.bump-version.outputs.new_version }}" + body: | + Bumps version from ${{ steps.current-version.outputs.version }} to ${{ steps.bump-version.outputs.new_version }}. + + This PR was automatically created by the version-bump workflow. + branch: version-bump-${{ steps.bump-version.outputs.new_version }} + labels: version-bump diff --git a/lib/workos/organization_membership.rb b/lib/workos/organization_membership.rb index 4943b5ad..8c8dcfb2 100644 --- a/lib/workos/organization_membership.rb +++ b/lib/workos/organization_membership.rb @@ -7,7 +7,7 @@ module WorkOS class OrganizationMembership include HashProvider - attr_accessor :id, :user_id, :organization_id, :status, :role, :roles, :created_at, :updated_at + attr_accessor :id, :user_id, :organization_id, :status, :role, :roles, :custom_attributes, :created_at, :updated_at def initialize(json) hash = JSON.parse(json, symbolize_names: true) @@ -18,6 +18,7 @@ def initialize(json) @status = hash[:status] @role = hash[:role] @roles = hash[:roles] + @custom_attributes = hash[:custom_attributes] @created_at = hash[:created_at] @updated_at = hash[:updated_at] end @@ -30,6 +31,7 @@ def to_json(*) status: status, role: role, roles: roles, + custom_attributes: custom_attributes, created_at: created_at, updated_at: updated_at, }