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