Skip to content

Commit

Permalink
chore(ci): allow triggering nightly build for PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed May 21, 2023
1 parent 6348e9a commit 45b3d9c
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 29 deletions.
71 changes: 71 additions & 0 deletions .github/actions/nightly-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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-branch:
description: 'Branch name'
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: ${{ env.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
- run: echo "FULL_VERSION=$(node -e "console.log(require('./lerna.json').version)")-${{ inputs.release-branch }}.${{ inputs.release-id }}" >> $GITHUB_ENV
shell: bash
- run: yarn lerna version $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 }}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/nightly-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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/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('RELEASE_ID', 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-branch: pr-${{ github.event.inputs.pr }}
release-id: ${{ env.RELEASE_ID }}
npm-tag: pr
npm-token: ${{ secrets.NPM_TOKEN }}
- 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 }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nightly Release
name: Scheduled Nightly Release
on:
workflow_dispatch:
schedule:
Expand All @@ -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 }}
Expand All @@ -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-branch: ${{ matrix.branch }}
release-id: ${{ env.RELEASE_ID }}
npm-tag: ${{ matrix.tag }}
npm-token: ${{ secrets.NPM_TOKEN }}

percy:
name: Visual regression tests
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 45b3d9c

Please sign in to comment.