diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 000000000..bfb6a5f1b --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,26 @@ +name: Publish +on: + workflow_run: + workflows: ['Tests'] + types: [completed] + +jobs: + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-20.04 + strategy: + # On a seulement 1 paquet donc pas besoin de matrix ici, mais c'est en + # prévision du paquet covid à venir. + matrix: + package: ['modele-social'] + steps: + - uses: actions/checkout@v2 + - run: yarn install --frozen-lockfile + - run: yarn workspace ${{ matrix.package }} run build + env: + NODE_ENV: production + - uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_PUBLISH_SECRET }} + dry-run: ${{ github.ref != 'refs/heads/master' }} + package: ./${{ matrix.package }}/package.json diff --git a/modele-social/CHANGELOG.md b/modele-social/CHANGELOG.md new file mode 100644 index 000000000..a404355cc --- /dev/null +++ b/modele-social/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.6.0 + +Publication du paquet sous forme d'ES modules. diff --git a/modele-social/check-changelog.js b/modele-social/check-changelog.js new file mode 100644 index 000000000..e875c9c28 --- /dev/null +++ b/modele-social/check-changelog.js @@ -0,0 +1,16 @@ +// Ensure that current package version is referenced in the Changelog.md +import { readFileSync } from 'fs' + +const packageVersion = JSON.parse( + readFileSync(new URL('./package.json', import.meta.url).pathname) +).version + +const changelog = readFileSync( + new URL('./CHANGELOG.md', import.meta.url).pathname +) + +if (!changelog.includes(`## ${packageVersion}\n`)) { + throw Error( + `Current version ${packageVersion} is not referenced in the CHANGELOG.md` + ) +} diff --git a/modele-social/package.json b/modele-social/package.json index 63546efd9..ee0a8b0b2 100644 --- a/modele-social/package.json +++ b/modele-social/package.json @@ -1,6 +1,6 @@ { "name": "modele-social", - "version": "0.5.0", + "version": "0.6.0", "description": "Les règles publicodes du système social français", "main": "./dist/index.js", "types": "./index.d.ts", @@ -28,6 +28,6 @@ "clean": "rimraf dist node_modules", "prepare": "yarn run build", "up": "yarn version --minor && echo \"ℹ N'oubliez pas de poussez le tag git\"", - "test": "echo 1" + "test": "node check-changelog.js" } } diff --git a/site/package.json b/site/package.json index bed00633c..7003f9dea 100644 --- a/site/package.json +++ b/site/package.json @@ -72,7 +72,7 @@ "algoliasearch": "^4.10.2", "fuse.js": "^6.4.6", "markdown-to-jsx": "^7.1.5", - "modele-social": "^0.5.0", + "modele-social": "^0.6.0", "publicodes": "^1.0.0-beta.30", "publicodes-react": "^1.0.0-beta.30", "ramda": "^0.27.0",