Release & 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: Release & Publish | |
on: | |
workflow_dispatch: | |
jobs: | |
validate-user: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Validate User | |
id: check | |
env: | |
GITHUB_TOKEN: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
run: | | |
response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/orgs/feathery-org/members/$GITHUB_ACTOR") | |
if echo "$response" | grep -q '"message": "Not Found"'; then | |
echo "$GITHUB_ACTOR is not a member of the organization. Exiting." | |
exit 1 | |
fi | |
setup: | |
runs-on: ubuntu-latest | |
needs: validate-user | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
- name: Setup Node.js and Cache | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
cache-dependency-path: '**/yarn.lock' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
build: | |
runs-on: ubuntu-latest | |
needs: setup | |
strategy: | |
matrix: | |
build-type: [ umd, node ] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
- name: Setup Node.js and Cache | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
cache-dependency-path: '**/yarn.lock' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build:${{ matrix.build-type }} | |
lint: | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
- name: Setup Node.js and Cache | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
cache-dependency-path: '**/yarn.lock' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Lint | |
run: yarn lint | |
test: | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
- name: Setup Node.js and Cache | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
cache-dependency-path: '**/yarn.lock' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Test | |
run: yarn test:ci | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- lint | |
- test | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
- name: Setup Node.js and Cache | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
cache-dependency-path: '**/yarn.lock' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Setup Git | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
- name: Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
run: yarn release -- --release-as patch | |
- name: Push Changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.FEATHERY_BOT_TOKEN }} | |
run: | | |
git push --follow-tags origin master | |
- name: Publish to NPM | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: yarn publish --non-interactive --new-version $(node -p "require('./package.json').version") |