|
| 1 | +name: Release (canary) |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches-ignore: |
| 5 | + - 'main' |
| 6 | + - 'changeset-release/main' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + if: ${{ github.repository == 'primer/eslint-plugin-primer-react' }} |
| 11 | + |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Set up Node.js |
| 21 | + uses: actions/setup-node@v2 |
| 22 | + with: |
| 23 | + node-version: 14.x |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: npm ci |
| 27 | + |
| 28 | + - name: Build |
| 29 | + run: npm run build --if-present |
| 30 | + |
| 31 | + - name: Create .npmrc |
| 32 | + run: | |
| 33 | + cat << EOF > "$HOME/.npmrc" |
| 34 | + //registry.npmjs.org/:_authToken=$NPM_TOKEN |
| 35 | + EOF |
| 36 | + env: |
| 37 | + NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }} |
| 38 | + |
| 39 | + - name: Publish canary version |
| 40 | + run: | |
| 41 | + echo "$( jq '.version = "0.0.0"' package.json )" > package.json |
| 42 | + echo -e "---\n'eslint-plugin-primer-react': patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md |
| 43 | + yarn changeset version --snapshot |
| 44 | + yarn changeset publish --tag canary |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + - name: Output canary version number |
| 49 | + |
| 50 | + with: |
| 51 | + script: | |
| 52 | + const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`) |
| 53 | + github.repos.createCommitStatus({ |
| 54 | + owner: context.repo.owner, |
| 55 | + repo: context.repo.repo, |
| 56 | + sha: context.sha, |
| 57 | + state: 'success', |
| 58 | + context: `Published ${package.name}`, |
| 59 | + description: package.version, |
| 60 | + target_url: `https://unpkg.com/${package.name}@${package.version}/` |
| 61 | + }) |
0 commit comments