Skip to content

feat: adds dev/release tag pipelines #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 0.49
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions .github/workflows/auth-react-test-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ on:
- reopened
- synchronize
push:
branches:
- master
- "v[0-9]+.[0-9]+"
tags:
- "(dev-)?v[0-9]+.[0-9]+.[0-9]+"
- dev-v[0-9]+.[0-9]+.[0-9]+

# Only one instance of this workflow will run on the same ref (PR/Branch/Tag)
# Previous runs will be cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
define-versions:
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ name: "Chromatic"

on:
push:
branches: [master, "[0-9]*.[0-9]*"]
branches:
- master
- "[0-9]*.[0-9]*"
tags:
- dev-v[0-9]+.[0-9]+.[0-9]+
workflow_dispatch:

# Only one instance of this workflow will run on the same ref (PR/Branch/Tag)
# Previous runs will be cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
chromatic:
runs-on: ubuntu-latest
Expand Down
153 changes: 153 additions & 0 deletions .github/workflows/pipeline-dev-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: "Dev Tag Pipeline"

on:
workflow_dispatch:
inputs:
branch:
description: The branch to create the dev tag on
type: string
required: true

permissions:
contents: write

jobs:
setup:
runs-on: ubuntu-latest

outputs:
packageVersion: ${{ steps.versions.outputs.packageVersion }}
packageVersionXy: ${{ steps.versions.outputs.packageVersionXy }}
packageLockVersion: ${{ steps.versions.outputs.packageLockVersion }}
packageLockVersionXy: ${{ steps.versions.outputs.packageLockVersionXy }}
newestVersion: ${{ steps.versions.outputs.newestVersion }}
targetBranch: ${{ steps.versions.outputs.targetBranch }}
devTag: ${{ steps.versions.outputs.devTag }}
releaseTag: ${{ steps.versions.outputs.releaseTag }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
# Need a complete fetch to make the master merge check work
fetch-depth: 0
fetch-tags: true
token: ${{ secrets.ALL_REPO_PAT }}

- name: Setup git
run: |
# NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com.
# See users API: https://api.github.com/users/github-actions%5Bbot%5D
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git fetch origin master

- name: Check if branch needs master merge
run: |
if [[ $(git log origin/master ^HEAD) != "" ]]; then
echo "You need to merge master into this branch."
exit 1
fi

- name: Populate variables
id: versions
run: |
. ./hooks/populate-hook-constants.sh
Copy link

Choose a reason for hiding this comment

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

Consider adding a step to ensure the script is executable before sourcing it:

chmod +x ./hooks/populate-hook-constants.sh
. ./hooks/populate-hook-constants.sh

This prevents potential permission issues after checkout, as Git doesn't always preserve executable permissions across systems.

Suggested change
. ./hooks/populate-hook-constants.sh
chmod +x ./hooks/populate-hook-constants.sh
. ./hooks/populate-hook-constants.sh

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.


echo "packageVersion=$packageVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "packageVersionXy=$packageVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "packageLockVersion=$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "packageLockVersionXy=$packageLockVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "newestVersion=$newestVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "targetBranch=$targetBranch" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"

echo "devTag=dev-v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "releaseTag=v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"

- name: Check tag and branch correctness
run: |
if [[ "${{ steps.versions.outputs.packageVersion }}" != "${{ steps.versions.outputs.packageLockVersion }}" ]]
then
echo "The package version and package lock version do not match."
exit 1
fi

if [[ "${{ steps.versions.outputs.packageVersion }}" != ${{ inputs.branch }}* ]]
Copy link

Choose a reason for hiding this comment

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

The branch comparison has a quoting issue that could lead to shell interpretation problems. The right side of the comparison should be quoted:

if [[ "${{ steps.versions.outputs.packageVersion }}" != "${{ inputs.branch }}"* ]]

This ensures that any special characters in the branch name are treated as literals rather than being interpreted by the shell.

Suggested change
if [[ "${{ steps.versions.outputs.packageVersion }}" != ${{ inputs.branch }}* ]]
if [[ "${{ steps.versions.outputs.packageVersion }}" != "${{ inputs.branch }}"* ]]

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

then
echo "Adding tag to wrong branch"
exit 1
fi

if git rev-parse ${{ steps.versions.outputs.releaseTag }} >/dev/null 2>&1
then
echo "The released version of this tag already exists."
exit 1
fi

- name: Delete tag if already tagged
run: |
git tag --delete ${{ steps.versions.outputs.devTag }} || true
git push --delete origin ${{ steps.versions.outputs.devTag }} || true

- name: Install dependencies
run: npm install

- name: Build docs
run: |
npm run build-pretty
npm run build-docs

- name: Commit doc changes
run: |
git add --all
git commit --allow-empty -nm "doc: update docs for ${{ steps.versions.outputs.releaseTag }} tag"
git push

- name: Create and push tag
run: |
# NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com.
# See users API: https://api.github.com/users/github-actions%5Bbot%5D
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git tag ${{ steps.versions.outputs.devTag }}
git push --tags --follow-tags

mark-dev-tag-as-not-passed:
runs-on: ubuntu-latest
needs:
- setup

steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.setup.outputs.devTag }}
fetch-tags: true

- id: versions
uses: supertokens/get-supported-versions-action@main
with:
has-cdi: false
has-fdi: true
has-web-js: true

- id: escape-versions
run: |
echo "fdiVersions=$(sed 's/"/\\"/g' <<< '${{ steps.versions.outputs.fdiVersions }}')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"
echo "webJsInterfaceVersion=$(sed 's/"/\\"/g' <<< '${{ steps.versions.outputs.webJsInterfaceVersion }}')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV"

- run: |
./hooks/populate-hook-constants.sh

curl --fail-with-body -X PUT \
https://api.supertokens.io/0/frontend \
-H 'Content-Type: application/json' \
-H 'api-version: 1' \
-d "{
\"password\": \"${{ secrets.SUPERTOKENS_API_KEY }}\",
\"version\":\"${{ needs.setup.outputs.packageVersion }}\",
\"name\": \"auth-react\",
\"frontendDriverInterfaces\": ${{ steps.escape-versions.outputs.fdiVersions }},
\"webJsInterface\": \"${{ steps.escape-versions.outputs.webJsInterfaceVersion }}\"
}"
Loading
Loading