Nightly Releases #583
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 Releases' | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
env: | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
nightly: | |
name: 'Nightly Release' | |
if: github.repository == 'pmndrs/react-spring' | |
runs-on: ubuntu-latest | |
outputs: | |
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }} | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.12.1 | |
with: | |
access_token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v4 | |
- name: Check for changes | |
id: version | |
run: | | |
# get latest commit sha | |
SHA=$(git rev-parse HEAD) | |
# get first 7 characters of sha | |
SHORT_SHA=${SHA::7} | |
# get latest nightly tag | |
LATEST_NIGHTLY_TAG=$(git tag -l v0.0.0-nightly-\* --sort=-creatordate | head -n 1) | |
# check if last commit to main 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" | |
exit 1 | |
else | |
# v0.0.0-nightly-<short sha>-<date> | |
NEXT_VERSION=nightly-${SHORT_SHA} | |
# set output so it can be used in other jobs | |
echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
- uses: actions/setup-node@v4 | |
if: steps.version.outputs.NEXT_VERSION | |
with: | |
node-version: 20 | |
cache: 'yarn' | |
- name: Install | |
if: steps.version.outputs.NEXT_VERSION | |
run: yarn install --immutable | |
- name: Build | |
if: steps.version.outputs.NEXT_VERSION | |
run: yarn build-ci | |
- name: Setup npmrc | |
if: steps.version.outputs.NEXT_VERSION | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc | |
- run: ./scripts/version-and-publish.sh | |
if: steps.version.outputs.NEXT_VERSION | |
env: | |
VERSION: ${{ steps.version.outputs.NEXT_VERSION }} | |
DIST_TAG: nightly | |
- name: Tag | |
uses: mathieudutour/github-tag-action@v6.2 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: '0.0.0-${{ steps.version.outputs.NEXT_VERSION }}' |