Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix npm release #737

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches:
- 'main'
- 'next_major'
workflow_dispatch:

jobs:
release:
name: Final
Expand Down Expand Up @@ -33,15 +35,6 @@ jobs:
- name: Build experimental tokens
run: npm run build:tokens

- id: get-access-token
uses: camertron/github-app-installation-auth-action@v1
with:
app-id: ${{ vars.PRIMER_APP_ID_SHARED }}
private-key: ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
client-id: ${{ vars.PRIMER_APP_CLIENT_ID_SHARED }}
client-secret: ${{ secrets.PRIMER_APP_CLIENT_SECRET_SHARED }}
installation-id: ${{ vars.PRIMER_APP_INSTALLATION_ID_SHARED }}

- name: Create release pull request or publish to npm
id: changesets
uses: changesets/action@v1.4.1
Expand All @@ -50,5 +43,5 @@ jobs:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: npm run release
env:
GITHUB_TOKEN: ${{ steps.get-access-token.outputs.access-token }}
GITHUB_TOKEN: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
66 changes: 12 additions & 54 deletions .github/workflows/release_canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,19 @@ on:
- 'changeset-release/**'
- 'dependabot/**'

permissions:
contents: write
pull-requests: write
checks: write
packages: write

jobs:
release-canary:
name: Canary
if: ${{ github.repository == 'primer/primitives' }}

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Install dependencies
run: npm ci --legacy-peer-deps --no-audit --no-fund --include=dev

- name: Build tokens
run: npm run build

- name: Build experimental tokens
run: npm run build:tokens

- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}

- name: Publish canary version
run: |
echo "$( jq '.version = "0.0.0"' package.json )" > package.json
echo -e "---\n'@primer/primitives': patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md
npx changeset version --snapshot
npx changeset publish --tag canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Output canary version number
uses: actions/github-script@v6.4.0
with:
script: |
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: 'success',
context: `Published ${package.name}`,
description: package.version,
target_url: `https://unpkg.com/${package.name}@${package.version}/`
})
uses: primer/.github/.github/workflows/release_canary.yml@main
with:
install: npm ci --legacy-peer-deps --no-audit --no-fund --include=dev && npm run build && npm run build:tokens
secrets:
gh_token: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
npm_token: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
1 change: 1 addition & 0 deletions .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- 'changeset-release/**'
workflow_dispatch:

jobs:
release-candidate:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"devDependencies": {
"@actions/github": "^5.1.1",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.22.0",
"@changesets/cli": "^2.26.1",
"@github/prettier-config": "^0.0.6",
"@playwright/test": "^1.35.1",
"@types/flat": "^5.0.1",
Expand Down
Loading