Deploy to Figma REST API from Design Tokens Repo (#136) #115
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: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
# Prevents changesets action from creating a PR on forks | |
if: github.repository == 'RedHat-UX/red-hat-design-tokens' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: .nvmrc | |
cache: npm | |
# Set up GitHub Actions caching for Wireit. | |
- uses: google/wireit@setup-github-actions-caching/v2 | |
- run: npm ci --prefer-offline | |
- run: npm run test | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
publish: npx changeset publish | |
commit: "chore: prepare release" | |
title: "chore: prepare release" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# changesets action outputs `publishedPackages` in the format | |
# [{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}] | |
# The following step converts that list of objects to a single string of form "1.0.0-beta.0" | |
- name: Transform Tags | |
id: get-tag | |
if: ${{ steps.changesets.outputs.published == 'true' }} | |
run: | | |
tag=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -c '.[0].version') | |
echo "$tag" | |
echo "::set-output name=tag::$tag" | |
- run: npm run package-vscode | |
- name: Upload release artifact | |
uses: actions/github-script@v6 | |
if: ${{ steps.changesets.outputs.published == 'true' }} | |
with: | |
debug: ${{ secrets.ACTIONS_RUNNER_DEBUG }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const workspace = '${{ github.workspace }}'; | |
const tag = 'v' + ${{ steps.get-tag.outputs.tag }}; | |
const { release } = await import('${{ github.workspace }}/lib/release.js'); | |
await release({ core, github, tag, workspace }); | |
- name: Publish VSCode | |
if: ${{ steps.changesets.outputs.published == 'true' }} | |
run: | | |
cd editor/vscode | |
npx vsce publish --pre-release | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} |