Skip to content

Commit 7e59cf5

Browse files
varlamcgee
andauthored
feat(release): support distribution tags and custom release user info (#292)
* feat(release): support distribution tags and custom release user info * ci(actions): add lint and test * chore(lint): resolve long-standing lint issues * ci(actions): update workflow templates Co-authored-by: Austin McGee <947888+amcgee@users.noreply.github.com>
1 parent c72a5e7 commit 7e59cf5

22 files changed

Lines changed: 216 additions & 109 deletions

File tree

.github/workflows/node-lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'dhis2-node lint'
2+
3+
on: push
4+
5+
jobs:
6+
check:
7+
runs-on: ubuntu-latest
8+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9+
steps:
10+
- uses: actions/checkout@v1
11+
- uses: actions/setup-node@v1
12+
with:
13+
node-version: 12.x
14+
15+
- name: Install
16+
run: yarn install --frozen-lockfile
17+
18+
- name: Run linters
19+
run: |
20+
npx d2-style js check
21+
npx d2-style text check
22+
env:
23+
CI: true

.github/workflows/node-publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'dhis2-node publish'
2+
3+
on:
4+
push:
5+
branches:
6+
# match branches in:
7+
# https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches
8+
- master
9+
- next
10+
- next-major
11+
- alpha
12+
- beta
13+
- '[0-9]+.x'
14+
- '[0-9]+.x.x'
15+
- '[0-9]+.[0-9]+.x'
16+
17+
env:
18+
GIT_AUTHOR_NAME: '@dhis2-bot'
19+
GIT_AUTHOR_EMAIL: 'apps@dhis2.org'
20+
GIT_COMMITTER_NAME: '@dhis2-bot'
21+
GIT_COMMITTER_EMAIL: 'apps@dhis2.org'
22+
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
23+
GH_TOKEN: ${{secrets.GH_TOKEN}}
24+
25+
jobs:
26+
publish:
27+
runs-on: ubuntu-latest
28+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
29+
steps:
30+
- uses: actions/checkout@v1
31+
- uses: actions/setup-node@v1
32+
with:
33+
node-version: 12.x
34+
35+
- name: Install
36+
run: yarn install --frozen-lockfile
37+
38+
- name: Smoke
39+
run: ./packages/main/bin/d2 debug system
40+
41+
- name: Test
42+
run: yarn test
43+
44+
- name: Publish to NPM
45+
run: npx @dhis2/cli-utils release --publish npm
46+
env:
47+
CI: true

.github/workflows/node-test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'dhis2-node test'
2+
3+
on: push
4+
5+
jobs:
6+
unit:
7+
runs-on: ubuntu-latest
8+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9+
steps:
10+
- uses: actions/checkout@v1
11+
- uses: actions/setup-node@v1
12+
with:
13+
node-version: 12.x
14+
15+
- name: Install
16+
run: yarn install --frozen-lockfile
17+
18+
- name: Test
19+
run: yarn test
20+
env:
21+
CI: true

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- - - `d2 create app`
1414
- - [`d2 style`↗️](https://cli-style.dhis2.nu ':ignore')
1515
- - `d2 utils`
16+
- - [`d2 utils release`](commands/d2-utils-release)
1617
- - - [`d2 utils docsite`↗️](https://cli-utils-docsite.dhis2.nu ':ignore')
1718
- &nbsp;
1819
- [Changelog](CHANGELOG)

docs/commands/d2-utils-release.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Introduction
2+
3+
`d2 utils release` allows you to publish libraries and applications to
4+
various package repositories.
5+
6+
# Usage
7+
8+
Internally the `release` command utilizes [semantic
9+
release](https://github.com/semantic-release/semantic-release), so
10+
understanding how that tool operates is helpful.
11+
12+
Simply put, every time a commit appears on the `master` branch, the
13+
fully automated release process begins, and the commit is released.
14+
15+
# Advanced usage
16+
17+
## Distribution channels
18+
19+
We support the default channels recommended by semantic release, and
20+
there is a [good
21+
walkthrough](https://github.com/semantic-release/semantic-release/blob/master/docs/recipes/distribution-channels.md)
22+
of them available on their docs.
23+
24+
Our [GH Actions
25+
workflow](https://github.com/dhis2/workflows/blob/master/ci/node-publish.yml#L5)
26+
is kept in sync with those defaults.
27+
28+
It is possible to e.g. only use the `master` branch for releases by
29+
restricting the `on.push.branches` list in the workflow file in the
30+
local repo.

docs/getting-started.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
# fo
1+
# Install the CLI
2+
3+
```
4+
yarn global add @dhis2/cli
5+
6+
# or
7+
8+
npm install --global @dhis2/cli
9+
```
10+
11+
# Verify that it is available on PATH
12+
13+
```
14+
d2 --version
15+
```

packages/app/src/commands/i18n/modernize.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
* --log-missing-keys
1212
*/
1313
const path = require('path')
14-
const fs = require('fs')
15-
const chalk = require('chalk')
1614

1715
const { reporter } = require('@dhis2/cli-helpers-engine')
1816

packages/app/src/helpers/modernize/createNewTranslationFiles.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const createNewTranslationFiles = ({
3636
appendToExistingFiles,
3737
}) => {
3838
for (const language in translations) {
39-
if (translations.hasOwnProperty(language)) {
39+
if (Object.prototype.hasOwnProperty.call(translations, language)) {
4040
if (
4141
languagesToTransform.length &&
4242
languagesToTransform.indexOf(language) === -1
@@ -88,7 +88,12 @@ const createNewTranslationFiles = ({
8888
}
8989

9090
for (const key in languageTranslations) {
91-
if (languageTranslations.hasOwnProperty(key)) {
91+
if (
92+
Object.prototype.hasOwnProperty.call(
93+
languageTranslations,
94+
key
95+
)
96+
) {
9297
if (!translations[primaryLanguage][key]) {
9398
logMissingKeys &&
9499
reporter.info(

packages/app/src/helpers/modernize/deleteLegacyFiles.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs')
2+
23
const { reporter } = require('@dhis2/cli-helpers-engine')
34

45
/**
@@ -16,7 +17,7 @@ const deleteLegacyFiles = ({ translationFiles, languagesToTransform }) => {
1617
languagesToTransform.indexOf(language) !== -1
1718
) {
1819
try {
19-
const filePathToDelete = path.join(inDir, file)
20+
const filePathToDelete = file
2021
fs.unlinkSync(filePathToDelete)
2122
reporter.debug(`Deleted old file:`)
2223
reporter.debug(`"${filePathToDelete}"`)

0 commit comments

Comments
 (0)