Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,69 @@ jobs:

- name: Run tests
run: mix test

# Each workload identity provider package is its own Mix project with its
# own release, so each is built and tested on its own, on the same version
# pairs as the SDK.
providers:
name: ${{ matrix.package }} (Elixir ${{ matrix.beam.elixir }} / OTP ${{ matrix.beam.otp }})

runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.package }}
strategy:
fail-fast: false
matrix:
package:
- workload_identity_github_actions
- workload_identity_gcp
- workload_identity_aws
beam:
- elixir: '1.20'
otp: '28'
- elixir: '1.19'
otp: '28'
- elixir: '1.18'
otp: '27'

steps:
- name: Check out this repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Set up Elixir and Erlang/OTP
uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
id: beam
with:
elixir-version: ${{ matrix.beam.elixir }}
otp-version: ${{ matrix.beam.otp }}

- name: Restore dependencies and build cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: mix-cache
with:
path: |
${{ matrix.package }}/deps
${{ matrix.package }}/_build
key: ${{ runner.os }}-otp-${{ steps.beam.outputs.otp-version }}-elixir-${{ steps.beam.outputs.elixir-version }}-mix-${{ env.MIX_ENV }}-${{ matrix.package }}-${{ hashFiles(format('{0}/mix.lock', matrix.package)) }}

- name: Install and compile dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
mix deps.get
mix deps.compile

- name: Save dependencies and build cache
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
if: steps.mix-cache.outputs.cache-hit != 'true'
with:
path: |
${{ matrix.package }}/deps
${{ matrix.package }}/_build
key: ${{ steps.mix-cache.outputs.cache-primary-key }}

- name: Compile with warnings as errors
run: mix compile --warnings-as-errors

- name: Run tests
run: mix test
62 changes: 62 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,68 @@ jobs:
- name: Run Credo
run: mix credo --strict -a

# The same checks for each workload identity provider package. Each is its
# own Mix project, so the root checks above do not reach them.
lint-providers:
name: Format & Credo (${{ matrix.package }})
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.package }}
strategy:
fail-fast: false
matrix:
package:
- workload_identity_github_actions
- workload_identity_gcp
- workload_identity_aws
steps:
- name: Check out this repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Set up Elixir and Erlang/OTP
uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
id: beam
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}

- name: Restore dependencies and build cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: mix-cache
with:
path: |
${{ matrix.package }}/deps
${{ matrix.package }}/_build
key: ${{ runner.os }}-otp-${{ steps.beam.outputs.otp-version }}-elixir-${{ steps.beam.outputs.elixir-version }}-mix-${{ env.MIX_ENV }}-${{ matrix.package }}-${{ hashFiles(format('{0}/mix.lock', matrix.package)) }}

- name: Install and compile dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
mix deps.get
mix deps.compile

- name: Save dependencies and build cache
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
if: steps.mix-cache.outputs.cache-hit != 'true'
with:
path: |
${{ matrix.package }}/deps
${{ matrix.package }}/_build
key: ${{ steps.mix-cache.outputs.cache-primary-key }}

- name: Check for unused dependencies
run: mix deps.unlock --check-unused

- name: Check formatting
run: mix format --check-formatted

- name: Compile with warnings as errors
run: mix compile --warnings-as-errors

- name: Run Credo
run: mix credo --strict -a

dialyzer:
name: Dialyzer
runs-on: ubuntu-latest
Expand Down
46 changes: 40 additions & 6 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ jobs:
# (changelog enrichment, release notes) can fail it.
release-please:
runs-on: ubuntu-latest
# `release_created` and `tag_name` describe the SDK (the root package)
# only. Each provider package has its own release PR, tag
# (`<package>-vX.Y.Z`) and outputs, keyed by its path. Publishing does not
# read these outputs: release.yml publishes on the `release: published`
# event and picks the package from the tag.
outputs:
pr: ${{ steps.release.outputs.pr }}
prs: ${{ steps.release.outputs.prs }}
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
github_actions_release_created: ${{ steps.release.outputs['workload_identity_github_actions--release_created'] }}
gcp_release_created: ${{ steps.release.outputs['workload_identity_gcp--release_created'] }}
aws_release_created: ${{ steps.release.outputs['workload_identity_aws--release_created'] }}
steps:
- name: Generate token
id: generate-token
Expand All @@ -48,10 +56,32 @@ jobs:
# release or any publish that depends on release-please.
enrich-release-pr:
needs: release-please
if: needs.release-please.outputs.pr
if: needs.release-please.outputs.prs
runs-on: ubuntu-latest
steps:
# Release PRs are separate per package, so `prs` can also hold a
# provider package's PR. Only the SDK's own PR is enriched: the
# .changelog-pending fragments and the root CHANGELOG.md belong to it.
# The provider PRs are the ones that name a workload_identity package
# in their branch or title.
- name: Select the SDK release PR
id: sdk-pr
env:
PRS_JSON: ${{ needs.release-please.outputs.prs }}
run: |
set -euo pipefail
pr="$(jq -c '[.[] | select((.headBranchName + " " + .title) | test("workload_identity") | not)][0] // empty' <<<"$PRS_JSON")"
if [ -z "$pr" ]; then
echo "No SDK release PR in this run; nothing to enrich."
exit 0
fi
{
echo "branch=$(jq -r '.headBranchName' <<<"$pr")"
echo "title=$(jq -r '.title' <<<"$pr")"
} >> "$GITHUB_OUTPUT"

- name: Generate token
if: steps.sdk-pr.outputs.branch
id: generate-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
Expand All @@ -61,9 +91,10 @@ jobs:
permission-pull-requests: write

- name: Checkout release PR branch
if: steps.sdk-pr.outputs.branch
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}
ref: ${{ steps.sdk-pr.outputs.branch }}
token: ${{ steps.generate-token.outputs.token }}

# Inline pending changelog fragments under the version heading
Expand All @@ -74,8 +105,9 @@ jobs:
# release-please wrote. Fragments are deleted in the same commit.
# Idempotent: if no fragments exist, skip silently.
- name: Inline rich changelog fragments
if: steps.sdk-pr.outputs.branch
env:
PR_JSON: ${{ needs.release-please.outputs.pr }}
PR_TITLE: ${{ steps.sdk-pr.outputs.title }}
run: |
set -euo pipefail
shopt -s nullglob
Expand All @@ -85,7 +117,7 @@ jobs:
exit 0
fi

VERSION=$(echo "$PR_JSON" | jq -r '.title' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
VERSION=$(echo "$PR_TITLE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
export VERSION

python3 - <<'PY'
Expand Down Expand Up @@ -157,7 +189,9 @@ jobs:
# After release-please tags the release and creates the GitHub Release,
# replace its body with the rich section from CHANGELOG.md (release-please
# writes only its terse default rendering). Cosmetic-only: never fails the
# release if the section can't be found.
# release if the section can't be found. SDK releases only: the plain
# `release_created` and `tag_name` outputs are the root package's, and
# provider releases keep release-please's default notes.
update-release-notes:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
Expand Down
119 changes: 119 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ defaults:
run:
shell: bash

# Every package in this repo has its own release and tag: `vX.Y.Z` for the SDK
# and `<package>-vX.Y.Z` for each workload identity provider package. Each
# published release runs this workflow once, and the tag decides which one job
# publishes.
jobs:
publish:
name: Publish to Hex
if: startsWith(github.event.release.tag_name, 'v')
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -46,3 +51,117 @@ jobs:
run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}

publish-workload-identity-github-actions:
name: Publish workos_workload_identity_github_actions to Hex
if: startsWith(github.event.release.tag_name, 'workos_workload_identity_github_actions-v')
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
shell: bash
working-directory: workload_identity_github_actions
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Set up Elixir and Erlang/OTP
uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
with:
# The minimum supported pair, as for the SDK.
elixir-version: '1.18'
otp-version: '27'

- name: Install dependencies
run: mix deps.get

- name: Verify tag matches mix.exs version
run: |
TAG_VERSION="${GITHUB_REF_NAME#workos_workload_identity_github_actions-v}"
MIX_VERSION="$(grep -oE '@version "[^"]+"' mix.exs | cut -d'"' -f2)"
if [ "$TAG_VERSION" != "$MIX_VERSION" ]; then
echo "Tag $GITHUB_REF_NAME does not match workload_identity_github_actions/mix.exs version $MIX_VERSION" >&2
exit 1
fi

- name: Publish to Hex
run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}

publish-workload-identity-gcp:
name: Publish workos_workload_identity_gcp to Hex
if: startsWith(github.event.release.tag_name, 'workos_workload_identity_gcp-v')
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
shell: bash
working-directory: workload_identity_gcp
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Set up Elixir and Erlang/OTP
uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
with:
# The minimum supported pair, as for the SDK.
elixir-version: '1.18'
otp-version: '27'

- name: Install dependencies
run: mix deps.get

- name: Verify tag matches mix.exs version
run: |
TAG_VERSION="${GITHUB_REF_NAME#workos_workload_identity_gcp-v}"
MIX_VERSION="$(grep -oE '@version "[^"]+"' mix.exs | cut -d'"' -f2)"
if [ "$TAG_VERSION" != "$MIX_VERSION" ]; then
echo "Tag $GITHUB_REF_NAME does not match workload_identity_gcp/mix.exs version $MIX_VERSION" >&2
exit 1
fi

- name: Publish to Hex
run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}

publish-workload-identity-aws:
name: Publish workos_workload_identity_aws to Hex
if: startsWith(github.event.release.tag_name, 'workos_workload_identity_aws-v')
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
shell: bash
working-directory: workload_identity_aws
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Set up Elixir and Erlang/OTP
uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
with:
# The minimum supported pair, as for the SDK.
elixir-version: '1.18'
otp-version: '27'

- name: Install dependencies
run: mix deps.get

- name: Verify tag matches mix.exs version
run: |
TAG_VERSION="${GITHUB_REF_NAME#workos_workload_identity_aws-v}"
MIX_VERSION="$(grep -oE '@version "[^"]+"' mix.exs | cut -d'"' -f2)"
if [ "$TAG_VERSION" != "$MIX_VERSION" ]; then
echo "Tag $GITHUB_REF_NAME does not match workload_identity_aws/mix.exs version $MIX_VERSION" >&2
exit 1
fi

- name: Publish to Hex
run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
5 changes: 4 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
".": "3.1.0"
".": "3.1.0",
"workload_identity_github_actions": "0.0.0",
"workload_identity_gcp": "0.0.0",
"workload_identity_aws": "0.0.0"
}
Loading
Loading