🌒 Nightly Release #954
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🌒 Nightly Release | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 7 * * *' # every day at 12AM PST | |
permissions: | |
issues: read | |
pull-requests: read | |
jobs: | |
nightly: | |
permissions: | |
contents: write | |
name: 🌒 Nightly Release | |
if: github.repository == 'hyperjumptech/monika' | |
runs-on: ubuntu-latest | |
outputs: | |
# allows this to be used in the `comment` job below | |
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }} | |
steps: | |
- name: 🛑 Cancel Previous Runs | |
uses: styfle/[email protected] | |
- name: ⬇️ Checkout repo | |
uses: actions/checkout@v4 | |
- name: 🔧 Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: 📥 Install Dependencies | |
run: npm ci | |
- run: npm run build -w packages/notification | |
- name: 🧪 Run Unit Tests | |
run: npm test | |
- name: ⤴️ Update Version if needed | |
id: version | |
run: | | |
# get latest commit sha | |
SHA=$(git rev-parse HEAD) | |
SHORT_SHA=${SHA::7} | |
# get latest nightly tag | |
LATEST_NIGHTLY_TAG=$(git tag -l v0.0.0-nightly-\* --sort=-taggerdate | head -n 1) | |
# check if last commit to dev starts would be the nightly tag we're about to create (minus the date) | |
# if it is, we'll skip the nightly creation | |
# if not, we'll create a new nightly tag | |
if [[ ${LATEST_NIGHTLY_TAG} == v0.0.0-nightly-${SHORT_SHA}-* ]]; then | |
echo "🛑 Latest nightly tag is the same as the latest commit sha, skipping nightly release" | |
else | |
git config --local user.email "[email protected]" | |
git config --local user.name "Monika Bot" | |
DATE=$(date '+%Y%m%d') | |
NEXT_VERSION=0.0.0-nightly-${DATE}-${SHORT_SHA} | |
echo ::set-output name=NEXT_VERSION::${NEXT_VERSION} | |
git checkout -b nightly/${NEXT_VERSION} | |
if [ -z "$(git status --porcelain)" ]; then | |
echo "✨" | |
else | |
echo "dirty working directory..." | |
git add . | |
git commit -m "dirty working directory..." | |
fi | |
npm version ${NEXT_VERSION} | |
fi | |
- name: 📦 Pack | |
run: npm pack | |
if: steps.version.outputs.NEXT_VERSION | |
- name: 📥 Install Pack | |
run: npm install -g ./hyperjumptech-monika-*.tgz | |
if: steps.version.outputs.NEXT_VERSION | |
- name: 🧪 Run Production Test | |
run: npm run prod_test | |
if: steps.version.outputs.NEXT_VERSION | |
- name: 🏷 Push Tag | |
if: steps.version.outputs.NEXT_VERSION | |
run: git push origin --tags | |
- name: 🔐 Setup npm auth | |
if: steps.version.outputs.NEXT_VERSION | |
run: | | |
echo "registry=https://registry.npmjs.org" >> ~/.npmrc | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | |
- name: 🚀 Publish | |
if: steps.version.outputs.NEXT_VERSION | |
run: npm publish --access public --tag nightly | |
- name: 💬 Notify Teams | |
if: steps.version.outputs.NEXT_VERSION | |
uses: joelwmale/webhook-action@fd99bb3b8272237103e349e9bb4d9b0ead9a217c | |
with: | |
url: ${{secrets.HYPERJUMP_TEAMS_SYMON_WEBHOOK}} | |
body: '{"title": "Monika Nightly NPM Release", "Text": "Version: ${{ steps.version.outputs.NEXT_VERSION }}"}' |