Skip to content

Commit 4f9366a

Browse files
committed
Add publishing GitHub jobs
1 parent 12d8260 commit 4f9366a

File tree

3 files changed

+80
-6
lines changed

3 files changed

+80
-6
lines changed

.github/workflows/check_version.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ jobs:
1414
uses: actions/checkout@v3
1515
with:
1616
fetch-depth: 0
17+
1718
- name: Use Node.js 18
1819
uses: actions/setup-node@v3
1920
with:
2021
node-version: 18
22+
2123
- name: Check version
2224
run: yarn version check

.github/workflows/release.yml

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create Release
1+
name: Release & Publish
22

33
on:
44
workflow_dispatch:
@@ -12,11 +12,22 @@ on:
1212

1313
permissions:
1414
contents: write
15+
packages: write
1516

1617
jobs:
17-
build:
18+
checks:
19+
name: Requirements
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check user permissions
23+
uses: 74th/[email protected]
24+
with:
25+
users: dedece35,glalloue,jhertout,jules-delecour-dav,olegoaer,zippy1978,utarwyn
26+
27+
release:
1828
name: Create release
1929
runs-on: ubuntu-latest
30+
needs: checks
2031
steps:
2132
- name: Checkout
2233
uses: actions/checkout@v3
@@ -28,18 +39,19 @@ jobs:
2839
with:
2940
node-version: 18
3041

31-
- name: Check version
32-
run: yarn version check
33-
3442
- name: Apply version
35-
run: yarn workspace @ecocode/${{ inputs.linter }} version apply
43+
run: yarn version apply
44+
working-directory: ${{ inputs.linter }}
3645

3746
- name: Get package version
3847
id: package-version
3948
uses: martinbeentjes/npm-get-version-action@main
4049
with:
4150
path: ${{ inputs.linter }}
4251

52+
- name: Check tag non-existence
53+
run: if git show-ref --tags --verify --quiet -- "refs/tags/${{ inputs.linter }}/${{ steps.package-version.outputs.current-version }}"; then echo "::error::Tag already exists" && exit 1; fi
54+
4355
- name: Extract release notes
4456
id: extract-release-notes
4557
uses: ffurrer2/extract-release-notes@v1
@@ -65,3 +77,58 @@ jobs:
6577
name: ${{ inputs.linter }} ${{ steps.package-version.outputs.current-version }}
6678
tag_name: ${{ inputs.linter }}/${{ steps.package-version.outputs.current-version }}
6779
body: ${{ steps.extract-release-notes.outputs.release_notes }}
80+
81+
publish-npm:
82+
runs-on: ubuntu-latest
83+
needs: release
84+
steps:
85+
- uses: actions/checkout@v3
86+
87+
- uses: actions/setup-node@v3
88+
with:
89+
node-version: 18
90+
registry-url: 'https://registry.npmjs.org'
91+
92+
- name: Install dependencies
93+
run: yarn install --immutable
94+
95+
- name: Copy LICENSE
96+
run: cp LICENSE.md ${{ inputs.linter }}/
97+
98+
- name: Publish package on NPM
99+
run: npm publish --access public --workspace ${{ inputs.linter }}
100+
env:
101+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
102+
103+
publish-github:
104+
runs-on: ubuntu-latest
105+
needs: release
106+
steps:
107+
- uses: actions/checkout@v3
108+
109+
- uses: actions/setup-node@v3
110+
with:
111+
node-version: 18
112+
113+
- name: Install dependencies
114+
run: yarn install --immutable
115+
116+
- name: Copy LICENSE
117+
run: cp LICENSE.md ${{ inputs.linter }}/
118+
119+
- name: Add scope to package name
120+
run: npx --workspace ${{ inputs.linter }} --yes change-package-name @${{ github.repository_owner }}/ecocode-${{ inputs.linter }}
121+
122+
- name: Configure GitHub Packages registry
123+
uses: bduff9/[email protected]
124+
with:
125+
dot-npmrc: |
126+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
127+
@${{ github.repository_owner }}:registry=https://npm.pkg.github.com
128+
always-auth=true
129+
working-directory: ${{ inputs.linter }}
130+
131+
- name: Publish package on GitHub Packages
132+
run: npm publish --workspace ${{ inputs.linter }}
133+
env:
134+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

eslint-plugin/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!lib/**/*
3+
!package.json
4+
!LICENSE.md
5+
!README.md

0 commit comments

Comments
 (0)