From 0e8a66f0c2fcc60d8dd2799282ca2bb05136be8f Mon Sep 17 00:00:00 2001 From: Mike Marcacci Date: Wed, 8 May 2024 15:47:24 -0700 Subject: [PATCH] fix release script (#662) * Fix release script * Use v3.1.0-alpha.52 constraints * use atomic push --- .github/workflows/ci.yml | 4 +- .github/workflows/main.yml | 78 ----------------------- .github/workflows/release.yml | 59 +++++++++++++++-- package-lock.json | 64 +++++++++---------- packages/authx/package.json | 2 +- packages/example/package.json | 18 +++--- packages/http-proxy-resource/package.json | 2 +- packages/http-proxy-web/package.json | 2 +- packages/interface/package.json | 6 +- packages/strategy-email/package.json | 6 +- packages/strategy-openid/package.json | 10 +-- packages/strategy-password/package.json | 6 +- packages/strategy-saml/package.json | 8 +-- packages/tools/package.json | 4 +- 14 files changed, 121 insertions(+), 148 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b8eb9d3..5dad6159 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4.1.4 - - name: Use Node 20 + - name: Use Node 22 uses: actions/setup-node@v4 with: - node-version: "20.x" + node-version: "22.x" - name: Cache node modules uses: actions/cache@v4.0.2 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 32a86bd2..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Deployment - -on: - release: - types: [published] - -jobs: - build: - runs-on: ubuntu-latest - - services: - postgres: - image: postgres:9.16 - env: - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - - steps: - - name: GenerateVersion - id: GenerateVersion - run: | - export BASE_VERSION="$GITHUB_REF" - echo "Base version is $BASE_VERSION" - [ ! -z "$BASE_VERSION" ] - export VERSION=`echo "$BASE_VERSION" | grep -Po '[0-9].*'` - echo "Version is $VERSION" - [ ! -z "$VERSION" ] - echo "::set-output name=version::$VERSION" - - uses: actions/checkout@v4.1.4 - - name: Use Node 20 - uses: actions/setup-node@v2.1.5 - with: - node-version: "20.x" - - name: Cache node modules - uses: actions/cache@v2.1.5 - with: - path: "**/node_modules" - key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.lock') }} - - name: Install Dependencies and Test - run: npm ci - - name: Build - run: npm run build - - name: Lint - run: npm run lint - - name: Test - run: npm run test - env: - PORT: 12000 - PGHOST: 127.0.0.1 - PGUSER: postgres - PGPASSWORD: postgres - PGPORT: 5432 - PGSSL: false - - name: Version - env: - VERSION: ${{ steps.GenerateVersion.outputs.version }} - run: | - npm run lerna version --no-git-tag-version -y "$VERSION" - npm run format - - name: Repush - env: - VERSION: ${{ steps.GenerateVersion.outputs.version }} - run: | - git config --global user.name 'Github Actions' - git config --global user.email 'githubactions' - git commit -am "v$VERSION" - git tag -f -a "v$VERSION" -m "v$VERSION" - git branch -va - git push -f --tags - git push origin HEAD:main - - name: Publish - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - VERSION: ${{ steps.GenerateVersion.outputs.version }} - run: | - lerna exec -- npm publish --access public --tag $VERSION - lerna exec -- npm publish --access public diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2a6099d..d685cba3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,18 +1,69 @@ name: Release on: - release: - types: [published] + workflow_dispatch: + inputs: + version: + required: true + jobs: build: runs-on: ubuntu-latest + + services: + postgres: + image: postgres:16 + env: + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + steps: + # Validate the version input + - name: Validate version + run: | + if ! [[ ${{ github.event.inputs.version }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\._-]+)?$ ]]; then + echo "Invalid version tag. Please use the format v1.2.3." + exit 1 + fi + + # Checkout the code - uses: actions/checkout@v4 - # Setup .npmrc file to publish to npm + + # Set up Node.js - uses: actions/setup-node@v4 with: node-version: "22.x" registry-url: "https://registry.npmjs.org" + + # Install, build, list, and test - run: npm ci - - run: npm publish --provenance --access public + - run: npm run build + - run: npm run lint + - run: node scripts/generate-keys.js && npm run test + env: + PORT: 12000 + PGHOST: 127.0.0.1 + PGUSER: postgres + PGPASSWORD: postgres + PGPORT: 5432 + PGSSL: false + + # Bump the version + - run: npx lerna version --no-git-tag-version -y "${{ github.event.inputs.version }}" + - run: npm run format + + # Commit and push + - run: | + git config --global user.name 'Github Actions' + git config --global user.email 'githubactions' + git commit -am "v$VERSION" + git tag -f -a "v$VERSION" -m "v$VERSION" + git branch -va + git push --atomic origin HEAD:main refs/tags/${{ github.event.inputs.version }} + + - run: git push --follow-tags + + # Publish the package to NPM + - run: npx lerna exec -- npm publish --access public --tag "${{ github.event.inputs.version }}" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package-lock.json b/package-lock.json index b3ee5ac3..8121c0fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18763,7 +18763,7 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/auth-header": "^1.0.6", "@types/graphql-relay": "^0.7.0", "@types/jsonwebtoken": "^9.0.6", @@ -18809,14 +18809,14 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/authx": "*", - "@authx/interface": "*", - "@authx/scopes": "*", - "@authx/strategy-email": "*", - "@authx/strategy-openid": "*", - "@authx/strategy-password": "*", - "@authx/strategy-saml": "*", - "@authx/tools": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/interface": "3.1.0-alpha.52", + "@authx/scopes": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52", + "@authx/strategy-openid": "3.1.0-alpha.52", + "@authx/strategy-password": "3.1.0-alpha.52", + "@authx/strategy-saml": "3.1.0-alpha.52", + "@authx/tools": "3.1.0-alpha.52", "@types/koa-send": "^4.1.6", "koa": "^2.15.3", "koa-send": "^5.0.1" @@ -18851,7 +18851,7 @@ "node": ">=10" }, "peerDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "koa": "^2.7.0" } }, @@ -18886,7 +18886,7 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/http-proxy": "^1.17.14", "@types/jsonwebtoken": "^9.0.6", "@types/node-fetch": "^2.6.11", @@ -18913,7 +18913,7 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/cookies": "^0.9.0", "@types/http-proxy": "^1.17.14", "@types/jsonwebtoken": "^9.0.6", @@ -18943,8 +18943,8 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/authx": "*", - "@authx/scopes": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/scopes": "3.1.0-alpha.52", "@tanstack/react-query": "^5.35.1", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", @@ -18972,7 +18972,7 @@ "node": ">=10" }, "peerDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "koa": "^2.7.0" } }, @@ -18999,7 +18999,7 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", @@ -19011,7 +19011,7 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "ava": "^6.1.3", @@ -19025,7 +19025,7 @@ "node": ">=10" }, "peerDependencies": { - "@authx/authx": "*" + "@authx/authx": "3.1.0-alpha.52" } }, "packages/strategy-openid": { @@ -19033,8 +19033,8 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/scopes": "*", - "@authx/strategy-email": "*", + "@authx/scopes": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", @@ -19046,7 +19046,7 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "ava": "^6.1.3", @@ -19060,8 +19060,8 @@ "node": ">=10" }, "peerDependencies": { - "@authx/authx": "*", - "@authx/strategy-email": "*" + "@authx/authx": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52" } }, "packages/strategy-password": { @@ -19069,7 +19069,7 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/bcrypt": "^5.0.2", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", @@ -19083,7 +19083,7 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "ava": "^6.1.3", @@ -19097,7 +19097,7 @@ "node": ">=10" }, "peerDependencies": { - "@authx/authx": "*" + "@authx/authx": "3.1.0-alpha.52" } }, "packages/strategy-saml": { @@ -19105,9 +19105,9 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/authx": "*", - "@authx/scopes": "*", - "@authx/strategy-email": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/scopes": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52", "@types/bcrypt": "^5.0.2", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", @@ -19138,7 +19138,7 @@ "node": ">=10" }, "peerDependencies": { - "@authx/authx": "*" + "@authx/authx": "3.1.0-alpha.52" } }, "packages/tools": { @@ -19146,8 +19146,8 @@ "version": "3.1.0-alpha.52", "license": "MIT", "dependencies": { - "@authx/authx": "*", - "@authx/strategy-password": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/strategy-password": "3.1.0-alpha.52", "@types/pg": "^8.11.6", "@types/uuid": "^9.0.8", "pg": "^8.11.5", diff --git a/packages/authx/package.json b/packages/authx/package.json index f5ec91bc..bb644d6b 100644 --- a/packages/authx/package.json +++ b/packages/authx/package.json @@ -5,7 +5,7 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/auth-header": "^1.0.6", "@types/graphql-relay": "^0.7.0", "@types/jsonwebtoken": "^9.0.6", diff --git a/packages/example/package.json b/packages/example/package.json index f7142640..9d7c2281 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -5,14 +5,14 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/authx": "*", - "@authx/interface": "*", - "@authx/scopes": "*", - "@authx/strategy-email": "*", - "@authx/strategy-openid": "*", - "@authx/strategy-password": "*", - "@authx/strategy-saml": "*", - "@authx/tools": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/interface": "3.1.0-alpha.52", + "@authx/scopes": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52", + "@authx/strategy-openid": "3.1.0-alpha.52", + "@authx/strategy-password": "3.1.0-alpha.52", + "@authx/strategy-saml": "3.1.0-alpha.52", + "@authx/tools": "3.1.0-alpha.52", "@types/koa-send": "^4.1.6", "koa": "^2.15.3", "koa-send": "^5.0.1" @@ -64,7 +64,7 @@ "main": "dist/server/index.js", "name": "@authx/example", "peerDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "koa": "^2.7.0" }, "repository": "https://github.com/the-control-group/authx", diff --git a/packages/http-proxy-resource/package.json b/packages/http-proxy-resource/package.json index db5750e7..0868c026 100644 --- a/packages/http-proxy-resource/package.json +++ b/packages/http-proxy-resource/package.json @@ -5,7 +5,7 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/http-proxy": "^1.17.14", "@types/jsonwebtoken": "^9.0.6", "@types/node-fetch": "^2.6.11", diff --git a/packages/http-proxy-web/package.json b/packages/http-proxy-web/package.json index 53173278..100952e1 100644 --- a/packages/http-proxy-web/package.json +++ b/packages/http-proxy-web/package.json @@ -5,7 +5,7 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/cookies": "^0.9.0", "@types/http-proxy": "^1.17.14", "@types/jsonwebtoken": "^9.0.6", diff --git a/packages/interface/package.json b/packages/interface/package.json index 7dafcf4e..c640ce79 100644 --- a/packages/interface/package.json +++ b/packages/interface/package.json @@ -5,8 +5,8 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/authx": "*", - "@authx/scopes": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/scopes": "3.1.0-alpha.52", "@tanstack/react-query": "^5.35.1", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", @@ -51,7 +51,7 @@ "main": "authx.js", "name": "@authx/interface", "peerDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "koa": "^2.7.0" }, "repository": "https://github.com/the-control-group/authx", diff --git a/packages/strategy-email/package.json b/packages/strategy-email/package.json index 4faa38ef..7a29940d 100644 --- a/packages/strategy-email/package.json +++ b/packages/strategy-email/package.json @@ -5,7 +5,7 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", @@ -18,7 +18,7 @@ }, "description": "", "devDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "ava": "^6.1.3", @@ -49,7 +49,7 @@ "main": "dist/server/index.js", "name": "@authx/strategy-email", "peerDependencies": { - "@authx/authx": "*" + "@authx/authx": "3.1.0-alpha.52" }, "repository": "https://github.com/the-control-group/authx", "scripts": { diff --git a/packages/strategy-openid/package.json b/packages/strategy-openid/package.json index c6af56f6..be561775 100644 --- a/packages/strategy-openid/package.json +++ b/packages/strategy-openid/package.json @@ -5,8 +5,8 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/scopes": "*", - "@authx/strategy-email": "*", + "@authx/scopes": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", @@ -19,7 +19,7 @@ }, "description": "", "devDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "ava": "^6.1.3", @@ -50,8 +50,8 @@ "main": "dist/server/index.js", "name": "@authx/strategy-openid", "peerDependencies": { - "@authx/authx": "*", - "@authx/strategy-email": "*" + "@authx/authx": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52" }, "repository": "https://github.com/the-control-group/authx", "scripts": { diff --git a/packages/strategy-password/package.json b/packages/strategy-password/package.json index 1bc2b393..6151f013 100644 --- a/packages/strategy-password/package.json +++ b/packages/strategy-password/package.json @@ -5,7 +5,7 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/scopes": "*", + "@authx/scopes": "3.1.0-alpha.52", "@types/bcrypt": "^5.0.2", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", @@ -20,7 +20,7 @@ }, "description": "", "devDependencies": { - "@authx/authx": "*", + "@authx/authx": "3.1.0-alpha.52", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "ava": "^6.1.3", @@ -51,7 +51,7 @@ "main": "dist/server/index.js", "name": "@authx/strategy-password", "peerDependencies": { - "@authx/authx": "*" + "@authx/authx": "3.1.0-alpha.52" }, "repository": "https://github.com/the-control-group/authx", "scripts": { diff --git a/packages/strategy-saml/package.json b/packages/strategy-saml/package.json index 6017146e..7cca34ed 100644 --- a/packages/strategy-saml/package.json +++ b/packages/strategy-saml/package.json @@ -1,9 +1,9 @@ { "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/authx": "*", - "@authx/scopes": "*", - "@authx/strategy-email": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/scopes": "3.1.0-alpha.52", + "@authx/strategy-email": "3.1.0-alpha.52", "@types/bcrypt": "^5.0.2", "@types/pg": "^8.11.6", "@types/react": "^18.3.1", @@ -52,7 +52,7 @@ "main": "dist/server/index.js", "name": "@authx/strategy-saml", "peerDependencies": { - "@authx/authx": "*" + "@authx/authx": "3.1.0-alpha.52" }, "repository": "https://github.com/the-control-group/authx", "scripts": { diff --git a/packages/tools/package.json b/packages/tools/package.json index 688e43c2..f4784635 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -8,8 +8,8 @@ }, "bugs": "https://github.com/the-control-group/authx/issues", "dependencies": { - "@authx/authx": "*", - "@authx/strategy-password": "*", + "@authx/authx": "3.1.0-alpha.52", + "@authx/strategy-password": "3.1.0-alpha.52", "@types/pg": "^8.11.6", "@types/uuid": "^9.0.8", "pg": "^8.11.5",