diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..6c5f593e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,62 @@ +name: Release + +on: + push: + tags: + - 'v*' +env: + BUILD_TMP: ./build-tmp + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout kanto + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout suite-connector + uses: actions/checkout@v2 + with: + repository: eclipse-kanto/suite-connector + path: ${{ env.BUILD_TMP }}/suite-connector' + ref: ${{ github.ref }} + token: ${{ secrets.WF_AUTH }} + - name: Checkout container-management + uses: actions/checkout@v2 + with: + repository: eclipse-kanto/container-management + path: ${{ env.BUILD_TMP }}/container-management + ref: ${{ github.ref }} + token: ${{ secrets.WF_AUTH }} + - name: Checkout file-upload + uses: actions/checkout@v2 + with: + repository: eclipse-kanto/file-upload + path: ${{ env.BUILD_TMP }}/file-upload + ref: ${{ github.ref }} + token: ${{ secrets.WF_AUTH }} + - name: Checkout software-update + uses: actions/checkout@v2 + with: + repository: eclipse-kanto/software-update + path: ${{ env.BUILD_TMP }}/software-update + ref: ${{ github.ref }} + token: ${{ secrets.WF_AUTH }} + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: ~> 1.5 + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index eb5f9bff..47b33070 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea/ .vscode/ +build-tmp/ +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..96ab130d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,433 @@ +env: + - GO111MODULE=on + - CGO_ENABLED=0 +builds: + # suite-connector builds + - id: build-suite-connector + dir: ./build-tmp/suite-connector + main: ./cmd/connector + binary: suite-connector/suite-connector + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w + mod_timestamp: '{{ .CommitTimestamp }}' + - id: build-suite-connector-deb + dir: ./build-tmp/suite-connector + main: ./cmd/connector + binary: suite-connector + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w + mod_timestamp: '{{ .CommitTimestamp }}' + # container-management builds + - id: build-container-management + dir: ./build-tmp/container-management + main: ./containerm/daemon + binary: container-management/container-management + env: + - VERSION_PKG=github.com/eclipse-kanto/container-management/containerm + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w -X {{ .Env.VERSION_PKG }}/version.GitCommit={{ .ShortCommit }} -X {{ .Env.VERSION_PKG }}/version.ProjectVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.APIVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.BuildTime={{ .Date }} + mod_timestamp: '{{ .CommitTimestamp }}' + - id: build-container-management-cli + dir: ./build-tmp/container-management + main: ./containerm/cli + binary: container-management/kanto-cm + env: + - VERSION_PKG=github.com/eclipse-kanto/container-management/containerm + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w -X {{ .Env.VERSION_PKG }}/version.GitCommit={{ .ShortCommit }} -X {{ .Env.VERSION_PKG }}/version.ProjectVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.APIVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.BuildTime={{ .Date }} + mod_timestamp: '{{ .CommitTimestamp }}' + - id: build-container-management-deb + dir: ./build-tmp/container-management + main: ./containerm/daemon + binary: container-management + env: + - VERSION_PKG=github.com/eclipse-kanto/container-management/containerm + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w -X {{ .Env.VERSION_PKG }}/version.GitCommit={{ .ShortCommit }} -X {{ .Env.VERSION_PKG }}/version.ProjectVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.APIVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.BuildTime={{ .Date }} + mod_timestamp: '{{ .CommitTimestamp }}' + - id: build-container-management-cli-deb + dir: ./build-tmp/container-management + main: ./containerm/cli + binary: kanto-cm + env: + - VERSION_PKG=github.com/eclipse-kanto/container-management/containerm + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w -X {{ .Env.VERSION_PKG }}/version.GitCommit={{ .ShortCommit }} -X {{ .Env.VERSION_PKG }}/version.ProjectVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.APIVersion={{ .Version }} -X {{ .Env.VERSION_PKG }}/version.BuildTime={{ .Date }} + mod_timestamp: '{{ .CommitTimestamp }}' + # file-upload builds + - id: build-file-upload + dir: ./build-tmp/file-upload + main: ./ + binary: file-upload/file-upload + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w + mod_timestamp: '{{ .CommitTimestamp }}' + - id: build-file-upload-deb + dir: ./build-tmp/file-upload + main: ./ + binary: file-upload + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w + mod_timestamp: '{{ .CommitTimestamp }}' + # software-update builds + - id: build-software-update + dir: ./build-tmp/software-update + main: ./cmd/software-update + binary: software-update/software-update + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w + mod_timestamp: '{{ .CommitTimestamp }}' + - id: build-software-update-deb + dir: ./build-tmp/software-update + main: ./cmd/software-update + binary: software-update + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + goarm: + - 7 + flags: + - -mod=readonly + - -v + - -trimpath + asmflags: + - all=-trimpath={{ .Env.GOPATH }} + gcflags: + - all=-trimpath={{ .Env.GOPATH }} + ldflags: + - -s -w + mod_timestamp: '{{ .CommitTimestamp }}' +archives: + - id: kanto-archive-all + builds: + - build-suite-connector + - build-container-management + - build-container-management-cli + - build-file-upload + - build-software-update + replacements: + amd64: x86_64 + files: + # common files + - LICENSE + # suite-connector additional files + - src: ./build-tmp/suite-connector/NOTICE.md + dst: suite-connector + strip_parent: true + info: + mode: 0644 + - src: ./build-tmp/suite-connector/cmd/connector/iothub.crt + dst: suite-connector + strip_parent: true + info: + mode: 0644 + # container-management additional files + - src: ./build-tmp/container-management/NOTICE.md + dst: container-management + strip_parent: true + info: + mode: 0644 + # file-upload additional files + - src: ./build-tmp/file-upload/NOTICE.md + dst: file-upload + strip_parent: true + info: + mode: 0644 + # software-update additional files + - src: ./build-tmp/software-update/NOTICE.md + dst: software-update + strip_parent: true + info: + mode: 0644 +nfpms: + - builds: + - build-suite-connector-deb + - build-container-management-deb + - build-container-management-cli-deb + - build-file-upload-deb + - build-software-update-deb + replacements: + amd64: x86_64 + maintainer: Contributors to the Eclipse Foundation, Kanto Project + description: |- + Eclipse Kantoâ„¢ is a modular IoT edge software that enables devices for IoT with all essentials + like cloud connectivity, digital twins, local communication, container management, + and software updates - all configurable and remotely manageable by an IoT cloud ecosystem of choice. + homepage: https://eclipse.org/kanto + license: EPL-2.0 + formats: + - deb + dependencies: + - containerd.io + - mosquitto + scripts: + postinstall: "build/postinst" + preremove: "build/prerm" + postremove: "build/postrm" + contents: + # suite-connector additional resources + - src: ./build-tmp/suite-connector/resources/suite-connector.service + dst: /etc/systemd/system/suite-connector.service + file_info: + mode: 0644 + - src: ./build-tmp/suite-connector/resources/config.json + dst: /etc/suite-connector/config.json + type: config + file_info: + mode: 0644 + - src: ./build-tmp/suite-connector/cmd/connector/iothub.crt + dst: /etc/suite-connector/iothub.crt + type: config + file_info: + mode: 0644 + - src: ./build-tmp/suite-connector/NOTICE.md + dst: /usr/share/doc/suite-connector/NOTICE.md + file_info: + mode: 0644 + - src: ./build-tmp/suite-connector/README.md + dst: /usr/share/doc/suite-connector/README.md + file_info: + mode: 0644 + - src: ./build-tmp/suite-connector/LICENSE + dst: /usr/share/doc/suite-connector/LICENSE + file_info: + mode: 0644 + - src: ./build/suite-connector.conf + dst: /etc/mosquitto/conf.d/suite-connector.conf + type: config + file_info: + mode: 0644 + # container-management additional resources + - src: ./build-tmp/container-management/containerm/resources/container-management.service + dst: /etc/systemd/system/container-management.service + file_info: + mode: 0644 + - src: ./build-tmp/container-management/containerm/resources/config.json + dst: /etc/container-management/config.json + type: config + file_info: + mode: 0644 + - src: ./build-tmp/container-management/NOTICE.md + dst: /usr/share/doc/container-management/NOTICE.md + file_info: + mode: 0644 + - src: ./build-tmp/container-management/README.md + dst: /usr/share/doc/container-management/README.md + file_info: + mode: 0644 + - src: ./build-tmp/container-management/LICENSE + dst: /usr/share/doc/container-management/LICENSE + file_info: + mode: 0644 + # file-upload additional resources + - src: ./build-tmp/file-upload/resources/file-upload.service + dst: /etc/systemd/system/file-upload.service + file_info: + mode: 0644 + - src: ./build-tmp/file-upload/resources/config.json + dst: /etc/file-upload/config.json + type: config + file_info: + mode: 0644 + - src: ./build-tmp/file-upload/NOTICE.md + dst: /usr/share/doc/file-upload/NOTICE.md + file_info: + mode: 0644 + - src: ./build-tmp/file-upload/README.md + dst: /usr/share/doc/file-upload/README.md + file_info: + mode: 0644 + - src: ./build-tmp/file-upload/LICENSE + dst: /usr/share/doc/file-upload/LICENSE + file_info: + mode: 0644 + # software-update additional resources + - src: ./build-tmp/software-update/resources/software-update.service + dst: /etc/systemd/system/software-update.service + file_info: + mode: 0644 + - src: ./build-tmp/software-update/resources/config.json + dst: /etc/software-update/config.json + type: config + file_info: + mode: 0644 + - src: ./build-tmp/software-update/NOTICE.md + dst: /usr/share/doc/software-update/NOTICE.md + file_info: + mode: 0644 + - src: ./build-tmp/software-update/README.md + dst: /usr/share/doc/software-update/README.md + file_info: + mode: 0644 + - src: ./build-tmp/software-update/LICENSE + dst: /usr/share/doc/software-update/LICENSE + file_info: + mode: 0644 +checksum: + name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +release: + #discussion_category_name: Announcement + prerelease: auto + mode: prepend + header: | + ## Eclipse Kanto {{ .Tag }} now available! + ### {{ .Date }} + + Check out what's new in Eclipse Kanto {{ .Tag }}! + footer: | + ## Sincere thanks to all contributors for making this release possible! \ No newline at end of file diff --git a/build/postinst b/build/postinst new file mode 100644 index 00000000..5a010ec4 --- /dev/null +++ b/build/postinst @@ -0,0 +1,77 @@ +# Automatically added by dh_systemd_enable/12.1.1bv2019.0b1 +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + deb-systemd-invoke restart 'mosquitto.service' >/dev/null || true + + # This will only remove masks created by d-s-h on package removal. + deb-systemd-helper unmask 'suite-connector.service' >/dev/null || true + + # was-enabled defaults to true, so new installations run enable. + if deb-systemd-helper --quiet was-enabled 'suite-connector.service'; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper enable 'suite-connector.service' >/dev/null || true + else + # Update the statefile to add new symlinks (if any), which need to be + # cleaned up on purge. Also remove old symlinks. + deb-systemd-helper update-state 'suite-connector.service' >/dev/null || true + fi + + # This will only remove masks created by d-s-h on package removal. + deb-systemd-helper unmask 'container-management.service' >/dev/null || true + + # was-enabled defaults to true, so new installations run enable. + if deb-systemd-helper --quiet was-enabled 'container-management.service'; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper enable 'container-management.service' >/dev/null || true + else + # Update the statefile to add new symlinks (if any), which need to be + # cleaned up on purge. Also remove old symlinks. + deb-systemd-helper update-state 'container-management.service' >/dev/null || true + fi + + # This will only remove masks created by d-s-h on package removal. + deb-systemd-helper unmask 'file-upload.service' >/dev/null || true + + # was-enabled defaults to true, so new installations run enable. + if deb-systemd-helper --quiet was-enabled 'file-upload.service'; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper enable 'file-upload.service' >/dev/null || true + else + # Update the statefile to add new symlinks (if any), which need to be + # cleaned up on purge. Also remove old symlinks. + deb-systemd-helper update-state 'file-upload.service' >/dev/null || true + fi + + # This will only remove masks created by d-s-h on package removal. + deb-systemd-helper unmask 'software-update.service' >/dev/null || true + + # was-enabled defaults to true, so new installations run enable. + if deb-systemd-helper --quiet was-enabled 'software-update.service'; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper enable 'software-update.service' >/dev/null || true + else + # Update the statefile to add new symlinks (if any), which need to be + # cleaned up on purge. Also remove old symlinks. + deb-systemd-helper update-state 'software-update.service' >/dev/null || true + fi +fi +# End automatically added section +# Automatically added by dh_systemd_start/12.1.1bv2019.0b1 +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + if [ -n "$2" ]; then + _dh_action=restart + else + _dh_action=start + fi + deb-systemd-invoke $_dh_action 'suite-connector.service' >/dev/null || true + deb-systemd-invoke $_dh_action 'container-management.service' >/dev/null || true + deb-systemd-invoke $_dh_action 'file-upload.service' >/dev/null || true + deb-systemd-invoke $_dh_action 'software-update.service' >/dev/null || true + fi +fi +# End automatically added section diff --git a/build/postrm b/build/postrm new file mode 100644 index 00000000..a2b5e917 --- /dev/null +++ b/build/postrm @@ -0,0 +1,31 @@ +# Automatically added by dh_systemd_start/12.1.1bv2019.0b1 +if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true +fi +# End automatically added section +# Automatically added by dh_systemd_enable/12.1.1bv2019.0b1 +if [ "$1" = "remove" ]; then + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper mask 'software-update.service' >/dev/null || true + deb-systemd-helper mask 'file-upload.service' >/dev/null || true + deb-systemd-helper mask 'container-management.service' >/dev/null || true + deb-systemd-helper mask 'suite-connector.service' >/dev/null || true + fi +fi + +if [ "$1" = "purge" ]; then + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper purge 'software-update.service' >/dev/null || true + deb-systemd-helper unmask 'software-update.service' >/dev/null || true + deb-systemd-helper purge 'file-upload.service' >/dev/null || true + deb-systemd-helper unmask 'file-upload.service' >/dev/null || true + deb-systemd-helper purge 'container-management.service' >/dev/null || true + deb-systemd-helper unmask 'container-management.service' >/dev/null || true + deb-systemd-helper purge 'suite-connector.service' >/dev/null || true + deb-systemd-helper unmask 'suite-connector.service' >/dev/null || true + fi +fi +if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then + deb-systemd-invoke restart 'mosquitto.service' >/dev/null || true +fi +# End automatically added section diff --git a/build/prerm b/build/prerm new file mode 100644 index 00000000..750b10a7 --- /dev/null +++ b/build/prerm @@ -0,0 +1,8 @@ +# Automatically added by dh_systemd_start/12.1.1bv2019.0b1 +if [ -d /run/systemd/system ] && [ "$1" = remove ]; then + deb-systemd-invoke stop 'software-update.service' >/dev/null || true + deb-systemd-invoke stop 'file-upload.service' >/dev/null || true + deb-systemd-invoke stop 'container-management.service' >/dev/null || true + deb-systemd-invoke stop 'suite-connector.service' >/dev/null || true +fi +# End automatically added section diff --git a/build/suite-connector.conf b/build/suite-connector.conf new file mode 100644 index 00000000..ec74d19d --- /dev/null +++ b/build/suite-connector.conf @@ -0,0 +1,4 @@ +log_dest topic +log_type notice +log_type subscribe +log_type unsubscribe