|
| 1 | +name: 🌒 Nightly Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "0 7 * * *" # every day at 12AM PST |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +env: |
| 13 | + CI: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + # HEADS UP! this "nightly" job will only ever run on the `main` branch due to |
| 17 | + # it being a cron job, and the last commit on main will be what github shows |
| 18 | + # as the trigger however in the checkout below we specify the `v7` branch, |
| 19 | + # so all the scripts in this job will be ran from that, confusing i know, so |
| 20 | + # in some cases we'll need to create multiple PRs when modifying nightly |
| 21 | + # release processes |
| 22 | + nightly: |
| 23 | + name: 🌒 Nightly Release |
| 24 | + if: github.repository == 'remix-run/react-router' |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + # allows this to be used in the `comment` job below - will be undefined |
| 28 | + # if there's no release necessary |
| 29 | + NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }} |
| 30 | + steps: |
| 31 | + - name: ⬇️ Checkout repo |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + ref: v7 |
| 35 | + # checkout using a custom token so that we can push later on |
| 36 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: 📦 Setup pnpm |
| 40 | + uses: pnpm/action-setup@v3.0.0 |
| 41 | + |
| 42 | + - name: ⎔ Setup node |
| 43 | + uses: actions/setup-node@v4 |
| 44 | + with: |
| 45 | + node-version-file: ".nvmrc" |
| 46 | + cache: "pnpm" |
| 47 | + |
| 48 | + - name: 📥 Install deps |
| 49 | + run: pnpm install --frozen-lockfile |
| 50 | + |
| 51 | + - name: 🕵️ Check for changes |
| 52 | + id: version |
| 53 | + run: | |
| 54 | + SHORT_SHA=$(git rev-parse --short HEAD) |
| 55 | +
|
| 56 | + # get latest nightly tag |
| 57 | + LATEST_NIGHTLY_TAG=$(git tag -l v0.0.0-nightly-\* --sort=-creatordate | head -n 1) |
| 58 | +
|
| 59 | + # check if last commit to v7 starts with the nightly tag we're about |
| 60 | + # to create (minus the date) |
| 61 | + # if it is, we'll skip the nightly creation |
| 62 | + # if not, we'll create a new nightly tag |
| 63 | + if [[ ${LATEST_NIGHTLY_TAG} == v0.0.0-nightly-${SHORT_SHA}-* ]]; then |
| 64 | + echo "🛑 Latest nightly tag is the same as the latest commit sha, skipping nightly release" |
| 65 | + else |
| 66 | + # yyyyMMdd format (e.g. 20221207) |
| 67 | + DATE=$(date '+%Y%m%d') |
| 68 | + # v0.0.0-nightly-<short sha>-<date> |
| 69 | + NEXT_VERSION=0.0.0-nightly-${SHORT_SHA}-${DATE} |
| 70 | + # set output so it can be used in other jobs |
| 71 | + echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_OUTPUT |
| 72 | + fi |
| 73 | +
|
| 74 | + - name: ⤴️ Update version |
| 75 | + if: steps.version.outputs.NEXT_VERSION |
| 76 | + run: | |
| 77 | + git config --local user.email "hello@remix.run" |
| 78 | + git config --local user.name "Remix Run Bot" |
| 79 | + git checkout -b nightly/${{ steps.version.outputs.NEXT_VERSION }} |
| 80 | + pnpm run version ${{steps.version.outputs.NEXT_VERSION}} |
| 81 | + git push origin --tags |
| 82 | +
|
| 83 | + - name: 🏗 Build |
| 84 | + if: steps.version.outputs.NEXT_VERSION |
| 85 | + run: pnpm build |
| 86 | + |
| 87 | + - name: 🔐 Setup npm auth |
| 88 | + if: steps.version.outputs.NEXT_VERSION |
| 89 | + run: | |
| 90 | + echo "registry=https://registry.npmjs.org" >> ~/.npmrc |
| 91 | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc |
| 92 | +
|
| 93 | + - name: 🚀 Publish |
| 94 | + if: steps.version.outputs.NEXT_VERSION |
| 95 | + run: pnpm run publish |
0 commit comments