Skip to content

Commit

Permalink
Merge pull request #1382 from SalesforceCommerceCloud/feature/nightly…
Browse files Browse the repository at this point in the history
…-releases

@W-13146921@: Setup github actions workflow for nightly releases
  • Loading branch information
shethj committed Jul 28, 2023
2 parents a7f7d68 + 1105da7 commit d8265a2
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 6 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/nightly_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: SalesforceCommerceCloud/pwa-kit/nightly_release
on:
workflow_dispatch:
schedule:
# Run weekdays at 12am (PST) - cron uses UTC times
- cron: "0 8 * * 1-5"

jobs:
create_nightly_release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get Timestamp
run: |-
echo "release_timestamp=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_ENV"
- name: Get monorepo version
run: |-
version=`jq -r ".version" package.json | cut -d "-" -f 1`
echo "monorepo_version_base=$version" >> "$GITHUB_ENV"
version_major=`echo "$version" | cut -d "." -f 1`
echo "monorepo_version_major=$version_major" >> "$GITHUB_ENV"
echo "nightly_version=${{ env.monorepo_version_base }}-nightly-${{ env.release_timestamp }}" ?? "$GITHUB_ENV"
- name: Get retail-react-app version
run: |-
version=`jq -r ".version" packages/template-retail-react-app/package.json | cut -d "-" -f 1`
echo "retail_app_version_base=$version" >> "$GITHUB_ENV"
- name: Get commerce-sdk-react version
run: |-
version=`jq -r ".version" packages/commerce-sdk-react/package.json | cut -d "-" -f 1`
echo "commerce_sdk_react_version_base=$version" >> "$GITHUB_ENV"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- name: Install Monorepo Dependencies
run: |-
# Install node dependencies
node ./scripts/gtime.js monorepo_install npm ci
- name: Create Release Branch
run: git switch release-nightly-${{ env.monorepo_version_major }}.x || git switch -c release-nightly-${{ env.monorepo_version_major }}.x

# Pull all changes from develop and keep changes from develop in case of merge-conflicts
- name: Pull latest changes from develop
run: |-
git switch develop
git merge -s ours release-nightly-${{ env.monorepo_version_major }}.x
git switch release-nightly-${{ env.monorepo_version_major }}.x
git merge develop
- name: Bump version (monorepo)
run: |-
npm run bump-version -- "${{ env.nightly_version }}"
- name: Bump version (retail-react-app)
run: |-
npm run bump-version:retail-react-app -- "${{ env.retail_app_version_base }}-nightly-${{ env.release_timestamp }}"
- name: Bump version (commerce-sdk-react)
run: |-
npm run bump-version:commerce-sdk-react -- "${{ env.commerce_sdk_react_version_base }}-nightly-${{ env.release_timestamp }}"
- name: Push branch to origin (Publish to NPM)
run: |-
git config --global user.name ${{ secrets.GIT_CONFIG_USERNAME }}
git config --global user.email ${{ secrets.GIT_CONFIG_EMAIL }}
git commit -am "Release ${{ env.nightly_version }}"
git push --set-upstream origin release-nightly-${{ env.monorepo_version_major }}.x
- name: Create git tag
run: |-
git tag v${{ env.nightly_version }}
git push origin --tags
- name: Send GitHub Action data to Slack workflow (Generated)
id: slack-success
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"test": "Successfully released PWA Kit v${{ env.nightly_version }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Send GitHub Action data to Slack workflow (Generated)
id: slack-failure
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"test": "Failed to release PWA Kit v${{ env.monorepo_version_base }}-nightly-${{ env.release_timestamp }}",
"link": `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ The PWA Kit is licensed under a BSD 3-Clause license. See the [license](./LICENS

Your contributions are welcome! Refer to the [CONTRIBUTING](./CONTRIBUTING.md) guide to get started. If you like `pwa-kit`, consider adding a ⭐ on the [GitHub Repo](https://github.com/SalesforceCommerceCloud/pwa-kit/). It helps other people discover PWA Kit!

## 🛠️ Nightly Builds

⚠️ PWA Kit releases nightly builds on a nightly cadence for better visibility about upcoming features and a chance for implementers to test code integrations via a "preview" release. These builds are untested and unsupported. Use at your own risk!
Nightly builds carry none of our guarantees associated with well-tested software. **Do not use these builds in production**.
Some feature included in the nightly builds may not be included in final PWA Kit releases.
These unreleased builds may not even load, may have undocumented features, known defects, and any number of other issues.
They are intended for use by developers and others wishing to get early access to planned PWA Kit features.

## 📖 Documentation

The full documentation for PWA Kit and Managed Runtime is hosted on the [Salesforce Developers](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/overview) portal.
Expand Down
18 changes: 12 additions & 6 deletions scripts/publish-to-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ const main = () => {
const packageName = matched && matched[1]

if (packageName) {
console.log(`--- Releasing ${packageName}...`)
publishPackages([packageName])
if (packageName === 'nightly') {
console.log('--- Releasing all packages...')
publishPackages([], true)
} else {
console.log(`--- Releasing ${packageName}...`)
publishPackages([packageName])
}
} else {
console.log('--- Releasing all packages...')
publishPackages()
Expand All @@ -37,8 +42,9 @@ const main = () => {

/**
* @param {string[]} packages - a list of package names without the "@salesforce" namespace
* @param {boolean} isNightly - boolean value suggesting if packages are being published as a nightly release (affects NPM tag)
*/
const publishPackages = (packages = []) => {
const publishPackages = (packages = [], isNightly = false) => {
verifyCleanWorkingTree()

const publicPackages = JSON.parse(sh.exec('lerna list --json', {silent: true}))
Expand Down Expand Up @@ -70,9 +76,9 @@ const publishPackages = (packages = []) => {
// https://github.com/lerna/lerna/tree/main/libs/commands/publish#publishconfigdirectory

const {stderr, code} = sh.exec(
`npm run lerna -- publish from-package --yes --no-verify-access --pre-dist-tag next ${
process.env.CI ? '' : '--registry http://localhost:4873/'
}`
`npm run lerna -- publish from-package --yes --no-verify-access --pre-dist-tag ${
isNightly ? 'nightly-next' : 'next'
} ${process.env.CI ? '' : '--registry http://localhost:4873/'}`
)
// DEBUG
// console.log('--- Would publish these public packages to npm:')
Expand Down

0 comments on commit d8265a2

Please sign in to comment.