Skip to content

Commit 3f8d5c2

Browse files
committed
Update release workflow due to GitHub limitations
1 parent 022f6bb commit 3f8d5c2

File tree

2 files changed

+125
-76
lines changed

2 files changed

+125
-76
lines changed

.github/workflows/publish.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
linter:
7+
description: 'Linter package to publish'
8+
required: true
9+
type: choice
10+
options:
11+
- eslint-plugin
12+
13+
permissions:
14+
contents: write
15+
packages: write
16+
17+
jobs:
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:
28+
name: Create GitHub release
29+
runs-on: ubuntu-latest
30+
needs: checks
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Get package version
38+
id: package-version
39+
run: echo "version=$(cat ${{ inputs.linter }}/package.json | jq -r '.version')" >> $GITHUB_OUTPUT
40+
41+
- name: Check tag non-existence
42+
run: if git show-ref --tags --verify --quiet -- "refs/tags/${{ inputs.linter }}/${{ steps.package-version.outputs.version }}"; then echo "::error::Tag already exists" && exit 1; fi
43+
44+
- name: Extract release notes
45+
id: extract-release-notes
46+
uses: ffurrer2/extract-release-notes@v1
47+
with:
48+
changelog_file: ${{ inputs.linter }}/CHANGELOG.md
49+
50+
- name: Create release
51+
uses: softprops/action-gh-release@v1
52+
with:
53+
name: ${{ inputs.linter }} ${{ steps.package-version.outputs.version }}
54+
tag_name: ${{ inputs.linter }}/${{ steps.package-version.outputs.version }}
55+
body: ${{ steps.extract-release-notes.outputs.release_notes }}
56+
57+
publish-npm:
58+
runs-on: ubuntu-latest
59+
needs: release
60+
steps:
61+
- uses: actions/checkout@v3
62+
63+
- uses: actions/setup-node@v3
64+
with:
65+
node-version: 18
66+
registry-url: 'https://registry.npmjs.org'
67+
68+
- name: Install dependencies
69+
run: yarn install --immutable
70+
71+
- name: Copy LICENSE
72+
run: cp LICENSE.md ${{ inputs.linter }}/
73+
74+
- name: Publish package on NPM
75+
run: npm publish --access public --workspace ${{ inputs.linter }}
76+
env:
77+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
79+
publish-github:
80+
runs-on: ubuntu-latest
81+
needs: release
82+
steps:
83+
- uses: actions/checkout@v3
84+
85+
- uses: actions/setup-node@v3
86+
with:
87+
node-version: 18
88+
89+
- name: Install dependencies
90+
run: yarn install --immutable
91+
92+
- name: Copy LICENSE
93+
run: cp LICENSE.md ${{ inputs.linter }}/
94+
95+
- name: Add scope to package name
96+
run: npx --workspace ${{ inputs.linter }} --yes change-package-name @${{ github.repository_owner }}/ecocode-${{ inputs.linter }}
97+
98+
- name: Configure GitHub Packages registry
99+
uses: bduff9/[email protected]
100+
with:
101+
dot-npmrc: |
102+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
103+
@${{ github.repository_owner }}:registry=https://npm.pkg.github.com
104+
always-auth=true
105+
working-directory: ${{ inputs.linter }}
106+
107+
- name: Publish package on GitHub Packages
108+
run: npm publish --workspace ${{ inputs.linter }}
109+
env:
110+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

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

33
on:
44
workflow_dispatch:
@@ -12,7 +12,7 @@ on:
1212

1313
permissions:
1414
contents: write
15-
packages: write
15+
pull-requests: write
1616

1717
jobs:
1818
checks:
@@ -25,7 +25,7 @@ jobs:
2525
users: dedece35,glalloue,jhertout,jules-delecour-dav,olegoaer,zippy1978,utarwyn
2626

2727
release:
28-
name: Create release
28+
name: Create release Pull Request
2929
runs-on: ubuntu-latest
3030
needs: checks
3131
steps:
@@ -45,12 +45,7 @@ jobs:
4545

4646
- name: Get package version
4747
id: package-version
48-
uses: martinbeentjes/npm-get-version-action@main
49-
with:
50-
path: ${{ inputs.linter }}
51-
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
48+
run: echo "version=$(cat ${{ inputs.linter }}/package.json | jq -r '.version')" >> $GITHUB_OUTPUT
5449

5550
- name: Extract release notes
5651
id: extract-release-notes
@@ -60,75 +55,19 @@ jobs:
6055
prerelease: true
6156

6257
- name: Update changelog
63-
uses: thomaseizinger/keep-a-changelog-new-release@v1
58+
uses: suyaser/keep-a-changelog-new-release@1.4.0
6459
with:
65-
tag: ${{ inputs.linter }}/${{ steps.package-version.outputs.current-version }}
60+
version: ${{ steps.package-version.outputs.version }}
61+
tag: ${{ inputs.linter }}/${{ steps.package-version.outputs.version }}
6662
changelogPath: ${{ inputs.linter }}/CHANGELOG.md
6763

68-
- name: Commit new version
69-
uses: EndBug/add-and-commit@v9
70-
with:
71-
message: Bump ${{ inputs.linter }} to ${{ steps.package-version.outputs.current-version }}
72-
default_author: github_actions
73-
74-
- name: Create release
75-
uses: softprops/action-gh-release@v1
64+
- name: Create pull request
65+
uses: peter-evans/create-pull-request@v4
7666
with:
77-
name: ${{ inputs.linter }} ${{ steps.package-version.outputs.current-version }}
78-
tag_name: ${{ inputs.linter }}/${{ steps.package-version.outputs.current-version }}
67+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
68+
branch: release-${{ inputs.linter }}-${{ steps.package-version.outputs.version }}
69+
commit-message: Bump ${{ inputs.linter }} to ${{ steps.package-version.outputs.version }}
70+
title: Release ${{ inputs.linter }} v${{ steps.package-version.outputs.version }}
7971
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 }}
72+
labels: release
73+
delete-branch: true

0 commit comments

Comments
 (0)