Skip to content

Commit 022f6bb

Browse files
authored
Merge pull request #3 from green-code-initiative/publish-action
Releasing and publishing process
2 parents 297d27c + c4385fb commit 022f6bb

File tree

10 files changed

+736
-10
lines changed

10 files changed

+736
-10
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check package version
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened ]
6+
7+
jobs:
8+
check-version:
9+
name: Check version bump
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Use Node.js 18
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 18
22+
23+
- name: Check version
24+
run: yarn version check

.github/workflows/release.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Release & Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
linter:
7+
description: 'Linter package to release'
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 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: Use Node.js 18
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: 18
41+
42+
- name: Apply version
43+
run: yarn version apply
44+
working-directory: ${{ inputs.linter }}
45+
46+
- name: Get package version
47+
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
54+
55+
- name: Extract release notes
56+
id: extract-release-notes
57+
uses: ffurrer2/extract-release-notes@v1
58+
with:
59+
changelog_file: ${{ inputs.linter }}/CHANGELOG.md
60+
prerelease: true
61+
62+
- name: Update changelog
63+
uses: thomaseizinger/keep-a-changelog-new-release@v1
64+
with:
65+
tag: ${{ inputs.linter }}/${{ steps.package-version.outputs.current-version }}
66+
changelogPath: ${{ inputs.linter }}/CHANGELOG.md
67+
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
76+
with:
77+
name: ${{ inputs.linter }} ${{ steps.package-version.outputs.current-version }}
78+
tag_name: ${{ inputs.linter }}/${{ steps.package-version.outputs.current-version }}
79+
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 }}

.yarn/plugins/@yarnpkg/plugin-version.cjs

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/versions/0a63a0fb.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
releases:
2+
"@ecocode/eslint-plugin": minor

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ nodeLinker: node-modules
33
plugins:
44
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
55
spec: "@yarnpkg/plugin-workspace-tools"
6+
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
7+
spec: "@yarnpkg/plugin-version"
68

79
yarnPath: .yarn/releases/yarn-3.4.1.cjs

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ The purpose of these linters is twofold: to allow code smells to be found as soo
2929
techonologies, and also to trace these reports back into SonarQube. This way we can make up for a SonarQube lack by
3030
improving feedback to developers. It's a good deal! And the use is not more complex.
3131

32-
🌿 Use with our SonarQube plugin
33-
--------------------------------
32+
🌿 Use with our SonarQube plugins
33+
---------------------------------
3434

35-
Not available right now. Coming soon!
35+
Linters in this repository are primally designed to work with our SonarQube plugins.\
36+
Check one of the guides below to install a SonarQube plugin and its associated linter:
37+
38+
- [JavaScript plugin guide](https://github.com/green-code-initiative/ecoCode/blob/main/javascript-plugin/README.md)
39+
- More to come..
3640

3741
🔧 Use as standalone linters
3842
----------------------------
@@ -46,7 +50,13 @@ Plugins are working nicely on their own! Follow instructions in the dedicated RE
4650
🛒 Distribution
4751
---------------
4852

49-
Plugins are available as dedicated NPM packages.\
53+
SonarQube plugins can be downloaded from _ecoCode_ repository.\
54+
Linters are available as dedicated NPM packages.
55+
56+
| SonarQube plugin | Linter name | Latest version |
57+
|:-------------------------------------|:--------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------|
58+
| [JavaScript][ecoCode-latest-release] | [@ecocode/eslint-plugin](eslint-plugin/README.md) | [![eslint-plugin version](https://img.shields.io/npm/v/@ecocode/eslint-plugin)](https://npmjs.com/package/@ecocode/eslint-plugin) |
59+
5060
You can follow changelogs on [GitHub Releases page](https://github.com/green-code-initiative/ecoCode-linter/releases).
5161

5262
🤝 Contribution
@@ -57,3 +67,5 @@ We are open to your suggestions and contributions! Open an issue or PR 🚀
5767

5868
Check out the [CONTRIBUTING.md](CONTRIBUTING.md) file
5969
and follow the various guides to start contributing.
70+
71+
[ecoCode-latest-release]: https://github.com/green-code-initiative/ecoCode/releases/latest

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

CHANGELOG.md renamed to eslint-plugin/CHANGELOG.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- First release of this plugin `ecoCode-linter`
1313
- Add `CONTRIBUTING.md`
14-
15-
16-
[unreleased]: https://github.com/green-code-initiative/ecoCode/compare/v0.0.1...HEAD
17-
18-
[0.0.1]: https://github.com/green-code-initiative/ecoCode/releases/tag/v0.0.1

eslint-plugin/CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ correctly with all its details. A tooling script makes this job very easy.
8989
The last step is to open a PR on this project with the implementation of the rule, and a second one on the ecoCode
9090
project with the list of updated rules. Keep an eye on the coverage of your rule implementation 👀
9191

92+
Please check the semantic version you wish to target with your development: `yarn version check -i`
93+
9294
This is the end of this guide, thank you for reading this far and contributing to the project 🙏.

eslint-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ecocode/eslint-plugin",
3-
"version": "0.1.0",
3+
"version": "0.0.0",
44
"description": "JavaScript linter of ecoCode project",
55
"keywords": [
66
"eslint",

0 commit comments

Comments
 (0)