Merge pull request #47 from IFRCGo/feature/upgrade-ci #13
Workflow file for this run
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 | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- run: npx changelogithub | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
- name: Check package version is up to date in gh-pages | |
run: | | |
PACKAGE_VERSION=`cat package.json | grep version | grep -oP "(\d+\.)?(\d+\.)?(\*|\d+)"` | |
PACKAGE_VERSION_IN_GH_PAGE=`cat gh-pages/package.json | grep '@ifrc-go/icons' | grep -oP "(\d+\.)?(\d+\.)?(\*|\d+)"` | |
[[ "$PACKAGE_VERSION" == "$PACKAGE_VERSION_IN_GH_PAGE" ]] || { | |
echo 'Make sure gh-pages is using the latest release version'; | |
exit 1; | |
} | |
- name: Install | |
run: yarn install | |
- name: Build | |
run: yarn build | |
publish-npm: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
registry-url: https://registry.npmjs.org/ | |
- name: Install | |
run: yarn install | |
- name: Build | |
run: yarn build | |
- name: Publish | |
run: yarn publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
deploy-page: | |
needs: publish-npm | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
defaults: | |
run: | |
working-directory: gh-pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install + Build | |
run: docker-compose up page-build | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: gh-pages/out | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |