|
| 1 | +name: "Dev Tag Pipeline" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + branch: |
| 7 | + description: The branch to create the dev tag on |
| 8 | + type: string |
| 9 | + required: true |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + setup: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + outputs: |
| 19 | + packageVersion: ${{ steps.versions.outputs.packageVersion }} |
| 20 | + packageVersionXy: ${{ steps.versions.outputs.packageVersionXy }} |
| 21 | + packageLockVersion: ${{ steps.versions.outputs.packageLockVersion }} |
| 22 | + packageLockVersionXy: ${{ steps.versions.outputs.packageLockVersionXy }} |
| 23 | + newestVersion: ${{ steps.versions.outputs.newestVersion }} |
| 24 | + targetBranch: ${{ steps.versions.outputs.targetBranch }} |
| 25 | + devTag: ${{ steps.versions.outputs.devTag }} |
| 26 | + releaseTag: ${{ steps.versions.outputs.releaseTag }} |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + ref: ${{ inputs.branch }} |
| 32 | + # Need a complete fetch to make the master merge check work |
| 33 | + fetch-depth: 0 |
| 34 | + fetch-tags: true |
| 35 | + token: ${{ secrets.ALL_REPO_PAT }} |
| 36 | + |
| 37 | + - name: Setup git |
| 38 | + run: | |
| 39 | + # NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com. |
| 40 | + # See users API: https://api.github.com/users/github-actions%5Bbot%5D |
| 41 | + git config user.name "github-actions[bot]" |
| 42 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 43 | +
|
| 44 | + git fetch origin master |
| 45 | +
|
| 46 | + - name: Check if branch needs master merge |
| 47 | + run: | |
| 48 | + if [[ $(git log origin/master ^HEAD) != "" ]]; then |
| 49 | + echo "You need to merge master into this branch." |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Populate variables |
| 54 | + id: versions |
| 55 | + run: | |
| 56 | + . ./hooks/populate-hook-constants.sh |
| 57 | +
|
| 58 | + echo "packageVersion=$packageVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 59 | + echo "packageVersionXy=$packageVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 60 | + echo "packageLockVersion=$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 61 | + echo "packageLockVersionXy=$packageLockVersionXy" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 62 | + echo "newestVersion=$newestVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 63 | + echo "targetBranch=$targetBranch" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 64 | +
|
| 65 | + echo "devTag=dev-v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 66 | + echo "releaseTag=v$packageLockVersion" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 67 | +
|
| 68 | + - name: Check tag and branch correctness |
| 69 | + run: | |
| 70 | + if [[ "${{ steps.versions.outputs.packageVersion }}" != "${{ steps.versions.outputs.packageLockVersion }}" ]] |
| 71 | + then |
| 72 | + echo "The package version and package lock version do not match." |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | +
|
| 76 | + if [[ "${{ steps.versions.outputs.packageVersion }}" != ${{ inputs.branch }}* ]] |
| 77 | + then |
| 78 | + echo "Adding tag to wrong branch" |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | +
|
| 82 | + if git rev-parse ${{ steps.versions.outputs.releaseTag }} >/dev/null 2>&1 |
| 83 | + then |
| 84 | + echo "The released version of this tag already exists." |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | +
|
| 88 | + - name: Delete tag if already tagged |
| 89 | + run: | |
| 90 | + git tag --delete ${{ steps.versions.outputs.devTag }} || true |
| 91 | + git push --delete origin ${{ steps.versions.outputs.devTag }} || true |
| 92 | +
|
| 93 | + - name: Install dependencies |
| 94 | + run: npm install |
| 95 | + |
| 96 | + - name: Build docs |
| 97 | + run: | |
| 98 | + npm run build-pretty |
| 99 | + npm run build-docs |
| 100 | +
|
| 101 | + - name: Commit doc changes |
| 102 | + run: | |
| 103 | + git add --all |
| 104 | + git commit --allow-empty -nm "doc: update docs for ${{ steps.versions.outputs.releaseTag }} tag" |
| 105 | + git push |
| 106 | +
|
| 107 | + - name: Create and push tag |
| 108 | + run: | |
| 109 | + # NOTE: The user email is {user.id}+{user.login}@users.noreply.github.com. |
| 110 | + # See users API: https://api.github.com/users/github-actions%5Bbot%5D |
| 111 | + git config user.name "github-actions[bot]" |
| 112 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 113 | +
|
| 114 | + git tag ${{ steps.versions.outputs.devTag }} |
| 115 | + git push --tags --follow-tags |
| 116 | +
|
| 117 | + mark-dev-tag-as-not-passed: |
| 118 | + runs-on: ubuntu-latest |
| 119 | + needs: |
| 120 | + - setup |
| 121 | + |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v4 |
| 124 | + with: |
| 125 | + ref: ${{ needs.setup.outputs.devTag }} |
| 126 | + fetch-tags: true |
| 127 | + |
| 128 | + - id: versions |
| 129 | + uses: supertokens/get-supported-versions-action@main |
| 130 | + with: |
| 131 | + has-cdi: false |
| 132 | + has-fdi: true |
| 133 | + has-web-js: true |
| 134 | + |
| 135 | + - id: escape-versions |
| 136 | + run: | |
| 137 | + echo "fdiVersions=$(sed 's/"/\\"/g' <<< '${{ steps.versions.outputs.fdiVersions }}')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 138 | + echo "webJsInterfaceVersion=$(sed 's/"/\\"/g' <<< '${{ steps.versions.outputs.webJsInterfaceVersion }}')" | tee -a "$GITHUB_OUTPUT" "$GITHUB_ENV" |
| 139 | +
|
| 140 | + - run: | |
| 141 | + ./hooks/populate-hook-constants.sh |
| 142 | +
|
| 143 | + curl --fail-with-body -X PUT \ |
| 144 | + https://api.supertokens.io/0/frontend \ |
| 145 | + -H 'Content-Type: application/json' \ |
| 146 | + -H 'api-version: 1' \ |
| 147 | + -d "{ |
| 148 | + \"password\": \"${{ secrets.SUPERTOKENS_API_KEY }}\", |
| 149 | + \"version\":\"${{ needs.setup.outputs.packageVersion }}\", |
| 150 | + \"name\": \"auth-react\", |
| 151 | + \"frontendDriverInterfaces\": ${{ steps.escape-versions.outputs.fdiVersions }}, |
| 152 | + \"webJsInterface\": \"${{ steps.escape-versions.outputs.webJsInterfaceVersion }}\" |
| 153 | + }" |
0 commit comments