install chalk, start work on new options file #25
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 | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- 'package.json' | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Fetch version from package.json | |
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
- name: Compare it to the latest release | |
id: compare | |
run: | | |
# https://stackoverflow.com/a/34899925 | |
latest=$(gh release list --json name,isLatest --jq '.[] | select(.isLatest)|.name') | |
if [ "$latest" = "v${{ env.version }}" ]; then | |
echo "No new version found" | |
exit 1 | |
fi | |
env: | |
# why do i need to specify this? | |
GH_TOKEN: ${{ github.token }} | |
- name: Install dependencies | |
run: bun i | |
- name: Build package | |
run: bun run build:prod | |
- name: Copy files into dist | |
run: | | |
cp package.json dist | |
cp README.md dist | |
- name: Upload build files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: dist | |
Publish: | |
needs: Build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Download build files | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
- name: Setup .nvmrc | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Publish package to npm | |
run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GithubRelease: | |
needs: Build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: Download build files | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
- name: Fetch version from package.json (again -_- stupid env bullshit) | |
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
- name: Zip build files | |
run: zip -r consol-${{ env.version }}-dist.zip ./** | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: v${{ env.version }} | |
tag_name: v${{ env.version }} | |
files: consol-${{ env.version }}-dist.zip | |
generate_release_notes: true |