diff --git a/.github/workflows/make-v2-release.yml b/.github/workflows/make-v2-release.yml new file mode 100644 index 0000000000..800fd8e8cc --- /dev/null +++ b/.github/workflows/make-v2-release.yml @@ -0,0 +1,77 @@ +name: Make Release v2 (pre-release) +on: + workflow_dispatch: {} +concurrency: + group: on-release-publish +jobs: + run-unit-tests: + uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml + publish-npm: + needs: run-unit-tests + # Needed as recommended by npm docs on publishing with provenance https://docs.npmjs.com/generating-provenance-statements + permissions: + id-token: write + contents: write + runs-on: ubuntu-latest + outputs: + RELEASE_VERSION: ${{ steps.set-release-version.outputs.RELEASE_VERSION }} + steps: + - name: Checkout code + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Setup NodeJS + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version: '18' + cache: 'npm' + - name: Setup auth tokens + run: | + npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" + - name: Setup dependencies + uses: ./.github/actions/cached-node-modules + - name: Version + run: | + # Version all packages to next major version (2.0.0) without pushing to git, generating changelog or running commit hooks + # Since the version stored in the lerna.json will always be a 1.x.x version, we manually set the version to 2.0.0 + npx lerna version major --force-publish --no-push --no-git-tag-version --no-commit-hooks --no-changelog --yes + - name: Set alpha iteration + run: | + # Get the current alpha version from npm i.e 2.0.0-alpha.0 -> 0, 2.0.0-alpha.1 -> 1 (default to -1 if no alpha versions exist = first pre-release) + ITERATION=$(npm show @aws-lambda-powertools/commons time --json | jq -r 'to_entries | map(select(.key | startswith("2.0.0-alpha"))) | sort_by(.key) | last | .key // "-1"') + # Write the new version to the file + echo "{ \"iteration\": $((ITERATION + 1)) }" > v2.json + - name: Increment version in UA + run: | + # Increment the version in the UA + echo "// this file is auto generated, do not modify\nexport const PT_VERSION = '2.0.0-alpha.$(jq -r '.iteration' v2.json)';" > packages/commons/src/version.ts + - name: Build + run: | + npm run build:prod -w packages/batch \ + -w packages/commons \ + -w packages/idempotency \ + -w packages/logger \ + -w packages/metrics \ + -w packages/parameters \ + -w packages/tracer + - name: Pack packages + run: | + npm pack -w packages/batch \ + -w packages/commons \ + -w packages/idempotency \ + -w packages/logger \ + -w packages/metrics \ + -w packages/parameters \ + -w packages/tracer + - name: Publish to npm + run: | + npm publish aws-lambda-powertools-batch-*.tgz --tag next --provenance + npm publish aws-lambda-powertools-commons-*.tgz --tag next --provenance + npm publish aws-lambda-powertools-idempotency-*.tgz --tag next --provenance + npm publish aws-lambda-powertools-logger-*.tgz --tag next --provenance + npm publish aws-lambda-powertools-metrics-*.tgz --tag next --provenance + npm publish aws-lambda-powertools-parameters-*.tgz --tag next --provenance + npm publish aws-lambda-powertools-tracer-*.tgz --tag next --provenance + - name: Set release version + id: set-release-version + run: | + VERSION="2.0.0-alpha.$(cat v2.json | jq .iteration -r)" + echo RELEASE_VERSION="$VERSION" >> "$GITHUB_OUTPUT"