From 5298c190eb0b427cdb8f4e711d9b33f8a166b501 Mon Sep 17 00:00:00 2001 From: Denny Pradipta Date: Mon, 6 Jun 2022 18:10:23 +0700 Subject: [PATCH] add nightly release (#682) * feat: upload checksum (#5) * Feat: Nightly workflow * Fix: Double checkout Co-authored-by: Nico Prananta --- .github/workflows/nightly-release.yml | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/nightly-release.yml diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml new file mode 100644 index 000000000..56728159c --- /dev/null +++ b/.github/workflows/nightly-release.yml @@ -0,0 +1,78 @@ +name: ๐ŸŒ’ Nightly Release + +on: + workflow_dispatch: + schedule: + - cron: "0 7 * * *" # every day at 12AM PST + +jobs: + # HEADS UP! this "nightly" job will only ever run on the `main` branch due to it being a cron job, + # and the last commit on main will be what github shows as the trigger + # however in the checkout below we specify the `dev` branch, so all the scripts + # in this job will be ran from that, confusing i know, so in some cases we'll need to create + # multiple PRs when modifying nightly release processes + nightly: + 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/cancel-workflow-action@0.9.1 + + - name: โฌ‡๏ธ Checkout repo + uses: actions/checkout@v3 + + - uses: actions/setup-node@v1 + with: + node-version: 14 + + - run: npm ci + + - run: npm test + + - name: โคด๏ธ Update Version + id: version + run: | + git config --local user.email "monika@hyperjump.tech" + git config --local user.name "Monika Bot" + SHA=$(git rev-parse HEAD) + SHORT_SHA=${SHA::7} + 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} + + - run: npm pack + + - run: npm install -g ./hyperjumptech-monika-*.tgz + + - run: npm run prod_test + + - name: ๐Ÿท Push Tag + run: git push origin --tags + + - name: ๐Ÿ” Setup npm auth + run: | + echo "registry=https://registry.npmjs.org" >> ~/.npmrc + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc + - name: ๐Ÿš€ Publish + run: npm run publish + + - name: ๐Ÿฑ Create GitHub release + uses: actions/create-release@v1 + with: + draft: false + prerelease: true + release_name: v${{ steps.version.outputs.NEXT_VERSION }} + tag_name: v${{ steps.version.outputs.NEXT_VERSION }} \ No newline at end of file