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

Fix version in runner and publish npm package #699

Merged
merged 7 commits into from
Nov 2, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/lib-ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ jobs:
node-version: ${{ needs.get_version.outputs.node-version }}
registry-url: 'https://npm.pkg.github.com/'
directory: servers/lib
package-name: ${{ vars.PACKAGE_NAME || '' }}
package-name: ${{ vars.NPM_LIBMS_PACKAGE_NAME || '' }}
secrets:
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-package-npm:
if: |
if: |
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))

name: Publish to NPM
Expand All @@ -155,7 +155,7 @@ jobs:
node-version: ${{ needs.get_version.outputs.node-version }}
registry-url: 'https://registry.npmjs.org'
directory: servers/lib
package-name: ${{ vars.PACKAGE_NAME || '' }}
package-name: ${{ vars.NPM_LIBMS_PACKAGE_NAME || '' }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN}}

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,3 @@ jobs:
yarn install
yarn build
yarn publish --access public


58 changes: 27 additions & 31 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- 'servers/execution/**'
workflow_dispatch:

env:
NODE_VERSION: 20

jobs:
test-runner:
name: Test digital twin runner
Expand All @@ -24,7 +27,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: "**/yarn.lock"

Expand All @@ -51,39 +54,32 @@ jobs:
files: servers/execution/runner/coverage/clover.xml
flags: dt-runner

publish-package:

publish-package-github:
if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))

name: Publish to GitHub Packages
runs-on: ubuntu-latest
needs: test-runner
permissions:
packages: write
contents: read
needs: [test-runner]
uses: ./.github/workflows/publish-npm.yml
with:
node-version: 20
registry-url: 'https://npm.pkg.github.com/'
directory: servers/execution/runner
package-name: ${{ vars.NPM_RUNNER_PACKAGE_NAME || '' }}
secrets:
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
cache-dependency-path: "**/yarn.lock"
always-auth: true
registry-url: 'https://npm.pkg.github.com/'
publish-package-npm:
if: |
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))

- name: Publish npm package
run: |
# copy README.md to project root
cp servers/execution/runner/README.md .
cd servers/execution/runner
yarn install
yarn build
yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Publish to GitHub Packages
needs: [test-runner]
uses: ./.github/workflows/publish-npm.yml
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
directory: servers/execution/runner
package-name: ${{ vars.NPM_RUNNER_PACKAGE_NAME || '' }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN}}
6 changes: 4 additions & 2 deletions docs/developer/github-actions.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Secrets for Github Action

The Github actions require the following secrets to be obtained
from [docker hub](hub.docker.com):
from [docker hub](hub.docker.com) and [npm](npmjs.com):

| Secret Name | Explanation |
|:---|:---|
| `DOCKERHUB_SCOPE` | Username or organization name on docker hub |
| `DOCKERHUB_USERNAME` | Username on docker hub |
| `DOCKERHUB_TOKEN` | API token to publish images to docker hub, with `Read`, `Write` and `Delete` permissions |
| `NPM_TOKEN` | Token to publish npm package to Nodejs registry. |
| `NPM_LIBMS_PACKAGE_NAME` | Name of npm package for lib microservice |
| `NPM_RUNNER_PACKAGE_NAME` | Name of npm package for runner microservice |

Remember to add these secrets to
[Github Secrets Setting](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository)
of your fork.
of your fork.
1 change: 1 addition & 0 deletions servers/execution/runner/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ of VS Code IDE. Launch the program using `yarn start` before using
the **runner.api.http**.

Please see [README](./README.md) for more information.

2 changes: 1 addition & 1 deletion servers/execution/runner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@into-cps-association/runner",
"version": "0.3.1",
"version": "0.3.2",
"description": "DT Runner",
"main": "dist/src/runner.js",
"repository": "https://github.com/into-cps-association/DTaaS.git",
Expand Down
5 changes: 3 additions & 2 deletions servers/execution/runner/src/config/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { readFileSync } from 'fs';
import Keyv from 'keyv';
import resolveFile from './util.js';

const PACKAGE_VERSION: string = '0.2.0';
const PACKAGE_VERSION: string = '0.3.2';
const DEFAULT_CONFIG_FILENAME = 'runner.yaml';

export function createCommand(name: string): [Command, Keyv] {
return [new Command(name), new Keyv()];
Expand All @@ -20,7 +21,7 @@ export default async function CLI(
.option(
'-c --config <string>',
'runner config file specified in yaml format',
'runner.yaml',
DEFAULT_CONFIG_FILENAME,
)
.helpOption('-h --help', 'display help')
.showHelpAfterError()
Expand Down
1 change: 1 addition & 0 deletions servers/lib/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ yarn publish #increments version, publishes to registry and adds a git tag
```bash
npm unpublish --registry http://localhost:4873/ @into-cps-association/[email protected]
```

4 changes: 0 additions & 4 deletions yarn.lock

This file was deleted.

Loading