From 0a13e9c255c2f840dd3a79f6afd7b038aee0d122 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 27 Nov 2023 14:45:12 -0700 Subject: [PATCH] chore: auto publish (#46) --- .github/workflows/release.yml | 76 ++++++++--------------------------- package.json | 3 +- 2 files changed, 18 insertions(+), 61 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c86169c..175a86d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -227,7 +227,7 @@ jobs: RELEASE_COMMENT_ID: ${{ needs.release.outputs.comment-id }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - npm exec --offline -- template-oss-release-manager --lockfile=false --publish=false + npm exec --offline -- template-oss-release-manager --lockfile=false --publish=true npm run rp-pull-request --ignore-scripts --if-present - name: Commit id: commit @@ -376,70 +376,26 @@ jobs: defaults: run: shell: bash + permissions: + deployments: write + id-token: write steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ fromJSON(needs.release.outputs.release).tagName }} - name: Setup Node uses: actions/setup-node@v3 - id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') - - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v - - name: View in Registry + node-version: 18.x + - name: Install npm@latest run: | - EXIT_CODE=0 - - function is_published { - if npm view "$@" --loglevel=error > /dev/null; then - echo 0 - else - echo 1 - fi - } - - for release in $(echo '${{ needs.release.outputs.releases }}' | jq -r '.[] | @base64'); do - name=$(echo "$release" | base64 --decode | jq -r .pkgName) - version=$(echo "$release" | base64 --decode | jq -r .version) - spec="$name@$version" - status=$(is_published "$spec") - if [[ "$status" -eq 1 ]]; then - echo "$spec ERROR" - EXIT_CODE=$status - else - echo "$spec OK" - fi - done - - exit $EXIT_CODE + npm i --prefer-online --no-fund --no-audit -g npm@latest + npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN} + - name: Publish + env: + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + run: npm publish --provenance --tag=latest post-release-integration: needs: [ release, release-integration ] diff --git a/package.json b/package.json index 97bbc42..b225fc3 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.20.0" + "version": "4.20.0", + "publish": true } }