From 3e2b5cbb2124b8fe59f573bcf79b564962e26564 Mon Sep 17 00:00:00 2001 From: Kael Date: Sun, 21 May 2023 17:29:06 +1000 Subject: [PATCH] chore(ci): allow triggering nightly build for PRs --- .github/actions/nightly-release/action.yml | 69 +++++++++++++++++++ .github/workflows/ci.yml | 2 +- .github/workflows/nightly-pr.yml | 47 +++++++++++++ .../{nightly.yml => nightly-schedule.yml} | 37 +++------- scripts/deploy.sh | 2 +- 5 files changed, 128 insertions(+), 29 deletions(-) create mode 100644 .github/actions/nightly-release/action.yml create mode 100644 .github/workflows/nightly-pr.yml rename .github/workflows/{nightly.yml => nightly-schedule.yml} (61%) diff --git a/.github/actions/nightly-release/action.yml b/.github/actions/nightly-release/action.yml new file mode 100644 index 00000000000..a36f3e3289b --- /dev/null +++ b/.github/actions/nightly-release/action.yml @@ -0,0 +1,69 @@ +name: Nightly Release +description: Automatically release nightly builds + +inputs: + checkout-repo: + description: 'Repository to checkout' + required: true + checkout-ref: + description: 'Ref to checkout' + required: true + release-id: + description: 'Release ID' + required: true + npm-tag: + description: 'NPM tag' + required: true + npm-token: + description: 'NPM token' + required: true + +outputs: + full-version: + description: 'Full version' + value: ${{ steps.get-version.outputs.full-version }} + +runs: + using: composite + steps: + - run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + shell: bash + - uses: actions/checkout@v2 + with: + repository: ${{ inputs.checkout-repo }} + ref: ${{ inputs.checkout-ref }} + fetch-depth: 0 + - uses: ./.github/actions/yarn-install + - run: >- + node -e " + const json = require('./lerna.json'); + delete json.command.publish.allowBranch; + fs.writeFileSync('./lerna.json', JSON.stringify(json, null, 2))" + shell: bash + - id: get-version + run: echo "full-version=$(node -e "console.log(require('./lerna.json').version)")-${{ inputs.release-id }}" >> $GITHUB_OUTPUT + shell: bash + - run: yarn lerna version ${{ steps.get-version.outputs.full-version }} --no-push --no-commit-hooks --force-publish --yes + shell: bash + - run: yarn conventional-changelog -p angular --outfile ./packages/vuetify/CHANGELOG.md -r 2 + shell: bash + - run: >- + node -e "fs.writeFileSync( + './package.json', + JSON.stringify({ ...require('./package.json'), name: '@vuetify/nightly' }, null, 2) + )" + shell: bash + working-directory: ./packages/vuetify + - run: yarn lerna run build --scope @vuetify/nightly + shell: bash + - run: yarn lerna run build --scope @vuetify/api-generator + shell: bash + - name: NPM Release + run: | + npm config set //registry.npmjs.org/:_authToken ${NPM_API_KEY:?} + npm publish ./packages/vuetify --tag ${{ inputs.npm-tag }} --access public + shell: bash + env: + NPM_API_KEY: ${{ inputs.npm-token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f200b7c85e..ae029f60e05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,7 +112,7 @@ jobs: run: bash scripts/deploy.sh env: NPM_API_KEY: ${{ secrets.NPM_TOKEN }} - TAG_NAME: ${{ env.RELEASE_TAG }} + RELEASE_TAG: ${{ env.RELEASE_TAG }} - name: GitHub release id: create_release run: yarn conventional-github-releaser -p vuetify diff --git a/.github/workflows/nightly-pr.yml b/.github/workflows/nightly-pr.yml new file mode 100644 index 00000000000..a66ff7b5631 --- /dev/null +++ b/.github/workflows/nightly-pr.yml @@ -0,0 +1,47 @@ +name: Nightly Release +on: + workflow_dispatch: + inputs: + pr: + description: 'Pull Request number' + required: false + type: string + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'vuetifyjs' }} + steps: + - uses: actions/checkout@v2 + - uses: actions/github-script@v6 + with: + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ github.event.inputs.pr }} + }) + core.exportVariable('CHECKOUT_REPO', pr.data.head.repo.full_name) + core.exportVariable('CHECKOUT_REF', pr.data.head.ref) + core.exportVariable('SHORT_SHA', pr.data.head.sha.slice(0, 7)) + - id: nightly-release + uses: ./.github/actions/nightly-release + with: + checkout-repo: ${{ env.CHECKOUT_REPO }} + checkout-ref: ${{ env.CHECKOUT_REF }} + release-id: pr-${{ github.event.inputs.pr }}.${{ env.SHORT_SHA }} + npm-tag: pr + npm-token: ${{ secrets.NPM_TOKEN }} + - uses: actions/checkout@v2 + - uses: actions/github-script@v6 + with: + script: | + const fullVersion = process.env.FULL_VERSION + const pr = await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ github.event.inputs.pr }}, + body: `:rocket: Nightly release published to [@vuetify/nightly@${fullVersion}](https://www.npmjs.com/package/@vuetify/nightly/v/${fullVersion}).` + }) + env: + FULL_VERSION: ${{ steps.nightly-release.outputs.full-version }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly-schedule.yml similarity index 61% rename from .github/workflows/nightly.yml rename to .github/workflows/nightly-schedule.yml index 361239565af..1a796988b79 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly-schedule.yml @@ -1,4 +1,4 @@ -name: Nightly Release +name: Scheduled Nightly Release on: workflow_dispatch: schedule: @@ -24,13 +24,7 @@ jobs: tag: 'v2-stable' - branch: 'v2-dev' tag: 'v2-dev' - env: - RELEASE_BRANCH: ${{ matrix.branch }} - RELEASE_TAG: ${{ matrix.tag }} steps: - - run: | - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" - uses: actions/checkout@v2 with: ref: ${{ matrix.branch }} @@ -43,26 +37,15 @@ jobs: echo "Last commit was more than 24 hours ago, skipping release" exit 1 fi - - uses: ./.github/actions/yarn-install - - run: yarn lerna version $(node -e "console.log(require('./lerna.json').version)")-$RELEASE_BRANCH.$(date +'%Y-%m-%d') --no-push --no-commit-hooks --force-publish --yes - - run: yarn conventional-changelog -p angular --outfile ./packages/vuetify/CHANGELOG.md -r 2 - - run: cat ./packages/vuetify/CHANGELOG.md - - run: >- - node -e "fs.writeFileSync( - './package.json', - JSON.stringify({ ...require('./package.json'), name: '@vuetify/nightly' }, null, 2) - )" - working-directory: ./packages/vuetify - - run: yarn lerna run build --scope @vuetify/nightly - - run: yarn lerna run build --scope @vuetify/api-generator - - run: ls -lah - - name: NPM Release - run: | - npm config set //registry.npmjs.org/:_authToken ${NPM_API_KEY:?} - npm publish ./packages/vuetify --tag $RELEASE_TAG --access public - env: - NPM_API_KEY: ${{ secrets.NPM_TOKEN }} - TAG_NAME: ${{ env.RELEASE_TAG }} + - run: echo "RELEASE_ID=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + - uses: ./.github/actions/nightly-release + with: + checkout-repo: ${{ github.repository }} + checkout-ref: ${{ matrix.branch }} + release-id: ${{ matrix.branch }}.${{ env.RELEASE_ID }} + npm-tag: ${{ matrix.tag }} + npm-token: ${{ secrets.NPM_TOKEN }} + - uses: actions/checkout@v2 percy: name: Visual regression tests diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 71112e72873..cd3b326e7e0 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -2,4 +2,4 @@ npm config set //registry.npmjs.org/:_authToken ${NPM_API_KEY:?} npm whoami -yarn lerna publish from-git --npm-tag $(node ./scripts/parse-npm-tag.js ${TAG_NAME:?}) --yes --no-verify-access +yarn lerna publish from-git --npm-tag $(node ./scripts/parse-npm-tag.js ${RELEASE_TAG:?}) --yes --no-verify-access