Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitelist files to publish + new GitHub workflow to auto tag / release / publish #153

Merged
merged 3 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/tag-release-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# GitHub Actions workflows:
# https://docs.github.com/en/actions

name: Create new `git tag`, create new GitHub release and publish to NPM

on:
push:
branches:
- master

jobs:
create-git-tag:
name: Create new `git tag`
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
new-tag: ${{ steps.detect-and-tag-new-version.outputs.tag }}
new-version: ${{ steps.detect-and-tag-new-version.outputs.current-version }}
old-version: ${{ steps.detect-and-tag-new-version.outputs.previous-version }}
steps:
- uses: actions/checkout@v2
with:
# Required to ensure git history is properly checked:
# https://github.com/salsify/action-detect-and-tag-new-version/blob/v2.0.1/README.md?plain=1#L11
fetch-depth: 2

- name: Detect and tag new version
id: detect-and-tag-new-version
uses: salsify/action-detect-and-tag-new-version@v2

create-github-release:
if: ${{ needs.create-git-tag.outputs.new-tag }}
name: Create new GitHub release
needs: create-git-tag
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: ncipollo/release-action@v1
env:
REPO_URL: '${{ github.server_url }}/${{ github.repository }}'
TAGS_DIFF: 'v${{ needs.create-git-tag.outputs.new-version }}...v${{ needs.create-git-tag.outputs.old-version }}'
with:
body: '${{ env.REPO_URL }}/compare/${{ env.TAGS_DIFF }}'
name: Release ${{ needs.create-git-tag.outputs.new-tag }}
tag: ${{ needs.create-git-tag.outputs.new-tag }}

publish-npm:
if: ${{ needs.create-git-tag.outputs.new-tag }}
name: Publish to NPM
needs: create-git-tag
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 12
# Required if we want to authenticate during the `npm publish`:
# https://github.com/actions/setup-node/blob/v2.4.1/action.yml#L15-L16
registry-url: https://registry.npmjs.org

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
33 changes: 0 additions & 33 deletions .npmignore

This file was deleted.

Empty file removed addon/.gitkeep
Empty file.
Empty file removed app/.gitkeep
Empty file.
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@
"name": "PeopleDoc",
"url": "https://github.com/peopledoc"
},
"directories": {
"doc": "doc",
"test": "tests"
},
"files": [
"/addon",
"/app",
"/config/environment.js",
"/initializers",
"/instance-initializers",
"/services",
"/types",
"/index.js",
"/tsconfig.json"
],
Comment on lines +26 to +36
Copy link
Member Author

@MrChocolatine MrChocolatine Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a reminder about what is going to happen, "what will be included in the publish?".

Initially, when this PR started and we did not have this entry package.json/files, but only our .npmignore, the files included in the publish were:

https://github.com/peopledoc/ember-cli-embedded/runs/3941184198?check_suite_focus=true#step:5:17

npm notice === Tarball Contents ===
npm notice 22B   .github/CODEOWNERS
npm notice 79B   app/initializers/embedded.js
npm notice 88B   app/instance-initializers/embedded.js
npm notice 63B   app/services/embedded.js
npm notice 87B   config/environment.js
npm notice 615B  index.js
npm notice 3.8kB package.json
npm notice 1.2kB tsconfig.json
npm notice 1.1kB LICENSE.md
npm notice 363B  app/README.md
npm notice 5.5kB README.md
npm notice 240B  initializers/embedded.d.ts
npm notice 246B  instance-initializers/embedded.d.ts
npm notice 354B  services/embedded.d.ts
npm notice 3.0kB addon/initializers/embedded.ts
npm notice 379B  addon/instance-initializers/embedded.ts
npm notice 851B  addon/services/embedded.ts
npm notice 199B  types/global.d.ts
npm notice 126B  types/dummy/index.d.ts
npm notice 2.1kB .github/workflows/ci.yml
npm notice 691B  .github/dependabot.yml
npm notice 683B  .github/workflows/publish-npm.yml

Some files of these files are always and automatically included during a publish, no matter what settings we apply (this is a rule from npm itself, we can't do anything):

https://docs.npmjs.com/cli/v6/configuring-npm/package-json#files

package.json
README
CHANGES / CHANGELOG / HISTORY
LICENSE / LICENCE
NOTICE
The file in the "main" field

Now, if we apply this rule from npm to our initial list of files + our whitelist from package.json/files, we should end up with:

npm notice === Tarball Contents ===
npm notice 79B   app/initializers/embedded.js
npm notice 88B   app/instance-initializers/embedded.js
npm notice 63B   app/services/embedded.js
npm notice 87B   config/environment.js
npm notice 615B  index.js
npm notice 3.8kB package.json
npm notice 1.2kB tsconfig.json
npm notice 1.1kB LICENSE.md
npm notice 363B  app/README.md
npm notice 5.5kB README.md
npm notice 240B  initializers/embedded.d.ts
npm notice 246B  instance-initializers/embedded.d.ts
npm notice 354B  services/embedded.d.ts
npm notice 3.0kB addon/initializers/embedded.ts
npm notice 379B  addon/instance-initializers/embedded.ts
npm notice 851B  addon/services/embedded.ts
npm notice 199B  types/global.d.ts
npm notice 126B  types/dummy/index.d.ts

"scripts": {
"build": "ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
Expand Down