Skip to content

Nightly Releases

Nightly Releases #1186

Workflow file for this run

name: 'Nightly Releases'
on:
schedule:
- cron: '0 0 * * *'
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
permissions:
contents: write
id-token: write
outputs:
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v6
- 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: ./.github/actions/setup
if: steps.version.outputs.NEXT_VERSION
with:
turbo-cache: 'true'
- name: Build
if: steps.version.outputs.NEXT_VERSION
run: pnpm 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 }}'