From 0de3085a853ff8e25fe358bfa6d01bf8ba96eb14 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 11 Oct 2024 11:36:12 -0400 Subject: [PATCH] v2.0.6 (#45) ### Change - Change to GitHub Container Registry - Change CI/CD to build to GitHub Container Registry - Change version to v2.0.6 ### Fix - Fix host reference on shutdown --------- Co-authored-by: Tom Hollingworth --- .github/workflows/main.yml | 44 +++++++++++++++++++++++++++++--------- Dockerfile | 2 +- README.md | 16 +++++++++----- chart/Chart.yaml | 2 +- chart/values.yaml | 2 +- docker-compose.yml | 6 +++--- package.json | 4 ++-- sonar-project.properties | 2 +- src/clients/sparkplug.js | 2 +- src/index.js | 4 ++-- 10 files changed, 57 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 680942c..3ceaa40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,21 +1,45 @@ name: Publish Docker on: - # Trigger the workflow on push request, - # but only for the master branch push: - branches: - - master - release: - # Only use the types keyword to narrow down the activity types that will trigger your workflow. - types: [published, created, edited] + tags: + - v* + # # Temporary to test the action + # branches: + # - my/current-branch jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - uses: actions/checkout@master - - name: Publish to Registry + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to GitHub Container Registry + if: ${{ github.ref_type == 'tag' }} # Only useful when testing actions on a branch + uses: docker/build-push-action@v6 + with: + push: true + tags: | + ghcr.io/libremfg/packml-simulator:${{ github.ref_name }} + ghcr.io/libremfg/packml-simulator:latest + # # Uncomment when testing actions on a branch + # - name: Publish to GitHub Container Registry on Branch + # if: ${{ github.ref_type == 'branch' }} + # uses: docker/build-push-action@v6 + # with: + # push: true + # tags: | + # ghcr.io/libremfg/packml-simulator:test + - name: Publish to DockerHub Registry + if: ${{ github.ref_type == 'tag' }} # Only useful when testing actions on a branch uses: elgohr/Publish-Docker-Github-Action@v5 with: - name: libremfg/packml-simulator + name: spruiktec/packml-simulator username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + password: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5303eb8..ec7ef94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.authors="tom@rhize.com" LABEL org.opencontainers.image.source="https://github.com/libremfg/PackML-MQTT-Simulator" LABEL org.opencontainers.image.url="https://www.libremfg.com/" LABEL org.opencontainers.image.vendor="Libre Technologies Inc" -LABEL org.opencontainers.image.version="2.0.5" +LABEL org.opencontainers.image.version="2.0.6" WORKDIR /machine diff --git a/README.md b/README.md index bf48c29..8a231e6 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Start your container with environmental variables. #### Basic MQTT Structure ```shell -$ docker run -it -e SITE=Site -e AREA=Area -e LINE=Line -e MQTT_URL=mqtt://broker.hivemq.com -m 30m libremfg/packml-simulator +$ docker run -it -e SITE=Site -e AREA=Area -e LINE=Line -e MQTT_URL=mqtt://broker.hivemq.com -m 30m ghcr.io/libremfg/packml-simulator 2020-06-22T03:13:49.301Z | info: Initializing 2020-06-22T03:13:49.817Z | info: Connected to mqtt://broker.hivemq.com:1883 2020-06-22T03:13:49.819Z | info: Site/Area/Line/Status/UnitModeCurrent : Production @@ -33,7 +33,7 @@ Once up and running, use an MQTT client to publish to .../Command/Reset and .../ #### SparkPlugB ```shell -$ docker run -it -e CLIENT_TYPE=sparkplugb -e SITE=Site -e AREA=Area -e LINE=Line -e MQTT_URL=mqtt://broker.hivemq.com -m 30m libremfg/packml-simulator +$ docker run -it -e CLIENT_TYPE=sparkplugb -e SITE=Site -e AREA=Area -e LINE=Line -e MQTT_URL=mqtt://broker.hivemq.com -m 30m ghcr.io/libremfg/packml-simulator 2020-06-22T03:13:49.301Z | info: Initializing 2020-06-22T03:13:49.817Z | info: Connected to mqtt://broker.hivemq.com:1883 2020-06-22T03:13:49.819Z | info: Site/Area/Line/Status/UnitModeCurrent : Production @@ -263,7 +263,7 @@ version: "2.4" services: greenville-packaging-line1: - image: libremfg/packml-simulator + image: ghcr.io/libremfg/packml-simulator environment: SITE: Greenville AREA: Packaging @@ -271,7 +271,7 @@ services: mem_limit: 30MB greenville-packaging-line2: - image: libremfg/packml-simulator + image: ghcr.io/libremfg/packml-simulator environment: SITE: Greenville AREA: Packaging @@ -279,7 +279,7 @@ services: mem_limit: 30MB greenville-cnc-line1: - image: libremfg/packml-simulator + image: ghcr.io/libremfg/packml-simulator environment: SITE: Greenville AREA: CNC @@ -299,6 +299,12 @@ For any issue, there are fundamentally three ways an individual can contribute: ## Changelog +- 2.0.6 + - Fix host reference on shutdown + - Change to GitHub Container Registry + - Update CI/CD to build to GitHub Container Registry + - Bump Revision + - 2.0.5 - Bump Revision - Change base docker image from node:12-alpine to node:20-alpine diff --git a/chart/Chart.yaml b/chart/Chart.yaml index 0c0ff57..55e1266 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -3,4 +3,4 @@ name: packml-sim description: PackML Machine Simulator type: application version: 0.0.2 -appVersion: 2.0.5 +appVersion: 2.0.6 diff --git a/chart/values.yaml b/chart/values.yaml index 4dfec33..84cc754 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -1,6 +1,6 @@ replicaCount: 3 image: - repository: libremfg/packml-simulator + repository: ghcr.io/libremfg/packml-simulator pullPolicy: IfNotPresent config: diff --git a/docker-compose.yml b/docker-compose.yml index 1e4f65f..a58de18 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "2.4" services: bathurst-packaging-line1: - image: libremfg/packml-simulator + image: ghcr.io/libremfg/packml-simulator environment: SITE: Bathurst AREA: Packaging @@ -13,7 +13,7 @@ services: mem_limit: 30MB bathurst-packaging-line2: - image: libremfg/packml-simulator + image: ghcr.io/libremfg/packml-simulator environment: SITE: Bathurst AREA: Packaging @@ -24,7 +24,7 @@ services: mem_limit: 30MB greenville-cnc-line1: - image: libremfg/packml-simulator + image: ghcr.io/libremfg/packml-simulator environment: SITE: Greenville AREA: CNC diff --git a/package.json b/package.json index 32d6233..16acb61 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "packaging-machine-language-mqtt-simulator", - "version": "2.0.5", + "version": "2.0.6", "description": "Manufacturing line simulator interfaced using PackML over MQTT.", "keywords": [ "packml", @@ -22,7 +22,7 @@ "test": "echo \"Error: no test specified\" && exit 1", "style": "standard", "quality": "sonar-scanner", - "build": "docker build . -t libremfg/packml-simulator" + "build": "docker build . -t ghcr.io/libremfg/packml-simulator" }, "author": "Libre Technologies Inc", "license": "MIT", diff --git a/sonar-project.properties b/sonar-project.properties index 87d1418..8502663 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=PackagingMachineLanguageSimulator sonar.projectName=Packaging Machine Language Simulator -sonar.projectVersion=2.0.5 +sonar.projectVersion=2.0.6 sonar.language=js sonar.sources=src sonar.sourceEncoding=UTF-8 diff --git a/src/clients/sparkplug.js b/src/clients/sparkplug.js index 35a3413..7bf38b6 100644 --- a/src/clients/sparkplug.js +++ b/src/clients/sparkplug.js @@ -118,7 +118,7 @@ class Client extends events.EventEmitter { { name: "Properties/OS Version", timestamp: timestamp, - value: "2.0.5", + value: "2.0.6", type: "String" }, { diff --git a/src/index.js b/src/index.js index fecd4a5..cf6d6c7 100644 --- a/src/index.js +++ b/src/index.js @@ -121,7 +121,7 @@ switch (global.config.CLIENT_TYPE) { } client.on('connect', (packet) => { - logger.info(`Connected to ${client.options().href || global.config.MQTT_URL}:${client.options().port}`) + logger.info(`Connected to ${client.options().href || client.options().host || global.config.MQTT_URL}:${client.options().port}`) state.observe('onEnterState', (lifecycle) => { const stateCurrent = helper.titleCase(lifecycle.to) logger.debug(`Entering State ${stateCurrent}`) @@ -139,7 +139,7 @@ client.on('connect', (packet) => { }) client.on('close', () => { - logger.info(`Disconnected from ${client.options().href || globalConfig.MQTT_URL}:${client.options().port}`) + logger.info(`Disconnected from ${client.options().href || client.globalConfig.MQTT_URL}:${client.options().port}`) }) // Handle PackML Commands