diff --git a/.dockerignore b/.dockerignore index 3dcf07a..784de1c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,6 @@ test_setup/ experiments/ dist/ .git/ +.github/ +.gitignore Dockerfile \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 276dca7..54a3fe0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,7 +49,7 @@ jobs: # target: "lint" # baseimg: "docker" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: @@ -69,7 +69,6 @@ jobs: - id: check uses: EndBug/version-check@v2 - with: diff-search: true token: ${{ secrets.GITHUB_TOKEN }} @@ -115,24 +114,46 @@ jobs: needs: [deploy-docker] permissions: contents: write - packages: write runs-on: ubuntu-latest steps: - - name: "Generate changelog" - id: changelog - uses: heinrichreimer/action-github-changelog-generator@v2.3 + - uses: actions/checkout@v4 + - name: Fetch tags + run: git fetch --prune --unshallow --tags + - name: Generate Release Message + id: message + uses: actions/github-script@v7 with: - token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }} + script: | + const last_release_resp = await github.rest.repos.getLatestRelease({ + owner: "matchlighter", + repo: "typedaemon", + }); + const last_release = last_release_resp?.data; + + const diff = last_release ? `refs/tags/${last_release.tag_name}..HEAD` : ""; + + let message = ''; + await exec.exec(`git log ${diff} --pretty=format:"- %h %s"`, [], { + listeners: { + stdout: (data) => { message += data.toString(); }, + } + }) + + core.setOutput("body", message.trim()); - name: Release + id: release uses: softprops/action-gh-release@v1 with: - body: ${{ steps.changelog.outputs.changelog }} + body: ${{ steps.message.outputs.body }} tag_name: ${{ needs.deploy-docker.outputs.version }} target_commitish: ${{ github.ref }} + prerelease: ${{ needs.deploy-docker.outputs.channel != 'release' }} outputs: - body: ${{ steps.changelog.outputs.changelog }} + body: ${{ steps.message.outputs.body }} + release_id: ${{ steps.release.outputs.id }} deploy-ha-addon-repo: if: ${{ !failure() && github.repository == 'matchlighter/typedaemon' && needs.deploy-docker.outputs.channel == 'release' }} @@ -140,17 +161,32 @@ jobs: needs: [deploy-docker, create-release] steps: - name: Trigger Workflow - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }} script: | - github.rest.actions.createWorkflowDispatch({ + let content = ${{ toJSON(github.event.release.body) }} || ${{ toJSON(needs.deploy-docker.outputs.body) }}; + + if (!content) { + const release_resp = await github.rest.repos.getRelease({ + owner: "matchlighter", + repo: "typedaemon", + release_id: ${{ needs.create-release.outputs.release_id }}, + }); + const release = release_resp.data; + console.log(release); + content = release.body; + } + + console.log(content); + + await github.rest.actions.createWorkflowDispatch({ owner: "matchlighter", repo: "typedaemon-hassio", workflow_id: "bump-version.yml", ref: "master", inputs: { version: "${{ needs.deploy-docker.outputs.version }}", - content: ${{ toJSON(github.event.release.body || needs.create-release.outputs.body) }} + content, } }) diff --git a/hassio.Dockerfile b/hassio.Dockerfile deleted file mode 100644 index 9bbf8a4..0000000 --- a/hassio.Dockerfile +++ /dev/null @@ -1,137 +0,0 @@ -ARG BUILD_FROM=ghcr.io/hassio-addons/base:14.0.0 -# hadolint ignore=DL3006 -FROM ${BUILD_FROM} - -# Copy Node-RED package.json -COPY package.json /opt/ -COPY node-red-dashboard-show-dashboard.patch /tmp/ - -# Set workdir -WORKDIR /opt - -# Set shell -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# Setup base -RUN \ - apk add --no-cache --virtual .build-dependencies \ - build-base=0.5-r3 \ - linux-headers=6.3-r0 \ - py3-pip=23.1.2-r0 \ - python3-dev=3.11.3-r11 \ - \ - && apk add --no-cache \ - git=2.40.1-r0 \ - icu-data-full=73.1-r1 \ - nginx=1.24.0-r6 \ - nodejs=18.16.0-r1 \ - npm=9.6.6-r0 \ - openssh-client=9.3_p1-r3 \ - patch=2.7.6-r10 \ - \ - && npm install \ - --no-audit \ - --no-fund \ - --no-update-notifier \ - --omit=dev \ - --unsafe-perm \ - && npm rebuild --build-from-source @serialport/bindings-cpp \ - \ - && npm cache clear --force \ - \ - && echo -e "StrictHostKeyChecking no" >> /etc/ssh/ssh_config \ - \ - && patch -d /opt/node_modules/node-red-dashboard -p1 \ - -i /tmp/node-red-dashboard-show-dashboard.patch \ - \ - && apk del --no-cache --purge .build-dependencies \ - && rm -fr \ - /etc/nginx \ - /root/.cache \ - /root/.npm \ - /root/.nrpmrc \ - /tmp/* - -# Copy root filesystem -COPY rootfs / - -# Health check -HEALTHCHECK --start-period=10m \ - CMD curl --fail http://127.0.0.1:46836 || exit 1 - -# Build arguments -ARG BUILD_ARCH -ARG BUILD_DATE -ARG BUILD_DESCRIPTION -ARG BUILD_NAME -ARG BUILD_REF -ARG BUILD_REPOSITORY -ARG BUILD_VERSION - -# Labels -LABEL \ - io.hass.name="${BUILD_NAME}" \ - io.hass.description="${BUILD_DESCRIPTION}" \ - io.hass.arch="${BUILD_ARCH}" \ - io.hass.type="addon" \ - io.hass.version=${BUILD_VERSION} \ - maintainer="Franck Nijhof " \ - org.opencontainers.image.title="${BUILD_NAME}" \ - org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ - org.opencontainers.image.vendor="Home Assistant Community Add-ons" \ - org.opencontainers.image.authors="Franck Nijhof " \ - org.opencontainers.image.licenses="MIT" \ - org.opencontainers.image.url="https://addons.community" \ - org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ - org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ - org.opencontainers.image.created=${BUILD_DATE} \ - org.opencontainers.image.revision=${BUILD_REF} \ - org.opencontainers.image.version=${BUILD_VERSION} - - - -FROM node:18 AS builder - -WORKDIR /opt/typedaemon_build - -# Install Deps -COPY package.json yarn.lock ./ -COPY patches patches -RUN yarn install --frozen-lockfile - -# Add App -COPY tsconfig.json ./ -COPY src/ ./src/ -RUN yarn build - -# Remove Dev Dependencies -# RUN yarn install --production --frozen-lockfile - -# Copy in non-compiled files -COPY . . -COPY ./docker/skel ./skel - -# Remove src -RUN rm -rf src/ node_modules/ docker/ - -WORKDIR /opt/typedaemon - -COPY ./docker . -RUN yarn install --production --no-lockfile -RUN yarn patch-package --patch-dir node_modules/typedaemon/patches/ - -# Build Runtime Image -FROM node:18 - -WORKDIR /opt/typedaemon - -COPY --from=builder /opt/typedaemon . - -RUN mv td /usr/bin/td \ - && chmod +x /usr/bin/td \ - && chmod +x ./startup.sh - -ENV TYPEDAEMON_ENV production -ENV TYPEDAEMON_CONFIG /config - -CMD [ "./startup.sh" ] diff --git a/package.json b/package.json index b84e536..3fa6a00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typedaemon", - "version": "0.3.3", + "version": "0.3.4", "license": "MIT", "main": "dist/index.js", "types": "dist/index.d.ts",