Skip to content

Merge pull request #18 from reservoirprotocol/changeset-release/main #28

Merge pull request #18 from reservoirprotocol/changeset-release/main

Merge pull request #18 from reservoirprotocol/changeset-release/main #28

Workflow file for this run

name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
packages: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Setup pnpm
run: sudo npm i -g pnpm
- name: Install Dependencies
run: pnpm install
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
- name: Generate Random Release Title
id: datamuse
run: |
title_case() {
echo "$1" | awk '{
for(i=1;i<=NF;i++){
$i=toupper(substr($i,1,1)) tolower(substr($i,2))
}
}1'
}
responseAdj=$(curl -s "https://api.datamuse.com/words?rel_jjb=animal&max=1000")
responseAnimal=$(curl -s "https://gist.githubusercontent.com/pedromcunha/d2b7f7b7e295cbafdd03af73bcd168ba/raw/c1d4b618da5051519c5d8ffce73d0ec6b018f356/animals.json")
lengthAdj=$(echo $responseAdj | jq length)
lengthAnimal=$(echo $responseAnimal | jq length)
random_index1=$(($RANDOM % lengthAdj))
random_index2=$(($RANDOM % lengthAnimal))
while [ $random_index1 -eq $random_index2 ]; do
random_index2=$(($RANDOM % length))
done
word1=$(echo $responseAdj | jq -r ".[$random_index1].word")
word2=$(echo $responseAnimal | jq -r ".[$random_index2].name")
title="$word1 $word2"
title=$(title_case "$title")
echo "Title is $title"
echo "RELEASE_TITLE=$title" >> $GITHUB_ENV
- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
with:
title: ${{ env.RELEASE_TITLE }}
publish: pnpm package:release