Skip to content

SalesforceCommerceCloud/pwa-kit/nightly_release #254

SalesforceCommerceCloud/pwa-kit/nightly_release

SalesforceCommerceCloud/pwa-kit/nightly_release #254

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
with:
fetch-depth: 0
- 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 nightly version
run: 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: Update identity in git config
run: |-
git config --global user.name ${{ secrets.GIT_CONFIG_USERNAME }}
git config --global user.email ${{ secrets.GIT_CONFIG_EMAIL }}
- name: Create Release Branch
run: |-
git pull
git switch develop
git switch nightly-releases || git switch -c nightly-releases
# 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 nightly-releases
git switch nightly-releases
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 version changes to origin
run: |-
git commit -am "Release ${{ env.nightly_version }}"
git push --set-upstream origin nightly-releases
- name: Check Repository Clean
uses: "./.github/actions/check_clean"
- name: Publish to NPM
uses: "./.github/actions/publish_to_npm"
with:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- 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: |
{
"message": "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: |
{
"message": "Failed to release PWA Kit v${{ env.monorepo_version_base }}-nightly-${{ env.release_timestamp }} (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}