Nightly npm package publish #19
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 npm package publish | |
env: | |
FOUNDRY_VERSION: nightly | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs every night at midnight | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
publish-npm: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel previous runs | |
if: github.event_name != 'schedule' | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Install GPG | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gnupg | |
- name: Import GPG key | |
env: | |
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
run: | | |
mkdir -p ~/.gnupg | |
chmod 700 ~/.gnupg | |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import | |
gpg --list-secret-keys --keyid-format LONG # Print all keys for debugging | |
KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | awk '/^sec/{print $2}' | awk -F'/' '{print $2}') | |
echo "GPG key ID: $KEY_ID" # Debug line to print the KEY_ID | |
echo "default-key $KEY_ID" >> ~/.gnupg/gpg.conf | |
echo "use-agent" >> ~/.gnupg/gpg.conf | |
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf | |
echo "KEY_ID=$KEY_ID" >> $GITHUB_ENV | |
- name: Set up Git user locally | |
run: | | |
git config user.name "GitHub Action Bot" | |
git config user.email "[email protected]" | |
git config commit.gpgSign true | |
git config user.signingkey ${{ env.KEY_ID }} | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: ${{ env.FOUNDRY_VERSION }} | |
- name: Print versions | |
run: ./scripts/print-versions.sh | |
- name: Authenticate to npm | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
- name: Check npm login | |
run: | | |
npm whoami || (echo "Not logged in to npm registry" && exit 1) | |
- name: Run Nightly Script | |
env: | |
GH_TOKEN: ${{ secrets.RIVER_GITHUB_PAT }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: ./scripts/publish-to-npm.sh |