From 78ab01284ffa4cf7148bdbcdd00f1964df7cc62b Mon Sep 17 00:00:00 2001 From: pkuehnel <35361981+pkuehnel@users.noreply.github.com> Date: Mon, 14 Mar 2022 02:09:47 +0100 Subject: [PATCH] Feat/cicd (#34) * feat(versionRelease): versionRelease * fix(versionRelease): remove second name * fix(versionRelease): use non specified .net version * fix(versionRelease): update files filter * feat(versionRelease): add docker push * fix(versionRelease): remove potential unnecessary tag * feat(versionRelease): add release Sma Energymeterplugin * feat(edgeRelease): add edge release --- .../{Release.yml => edgeRelease.yml} | 4 +- .github/workflows/versionRelease.yml | 140 ++++++++++++++++++ .../Server/.config/dotnet-tools.json | 12 ++ 3 files changed, 154 insertions(+), 2 deletions(-) rename .github/workflows/{Release.yml => edgeRelease.yml} (92%) create mode 100644 .github/workflows/versionRelease.yml create mode 100644 SmartTeslaAmpSetter/Server/.config/dotnet-tools.json diff --git a/.github/workflows/Release.yml b/.github/workflows/edgeRelease.yml similarity index 92% rename from .github/workflows/Release.yml rename to .github/workflows/edgeRelease.yml index 3c7a6105e..066cfdd3e 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/edgeRelease.yml @@ -31,7 +31,7 @@ jobs: file: ./SmartTeslaAmpSetter/Server/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: pkuehnel/smartteslaampsetter:latest + tags: pkuehnel/smartteslaampsetter:edge SmaEnergymeterplugin: name: Building SMAPlugin Image @@ -57,4 +57,4 @@ jobs: file: ./Plugins.SmaEnergymeter/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: pkuehnel/smartteslaampsettersmaplugin:latest + tags: pkuehnel/smartteslaampsettersmaplugin:edge diff --git a/.github/workflows/versionRelease.yml b/.github/workflows/versionRelease.yml new file mode 100644 index 000000000..be7a7456b --- /dev/null +++ b/.github/workflows/versionRelease.yml @@ -0,0 +1,140 @@ +name: versionRelease +on: + release: + types: [published] + +jobs: + releaseFiles: + name: Release + strategy: + matrix: + kind: ['linux-x64', 'linux-arm64'] + include: + - kind: linux-x64 + os: ubuntu-latest + target: linux-x64 + - kind: linux-arm64 + os: ubuntu-latest + target: linux-arm64 + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + + - name: Build SmartTeslaAmpSetter + shell: bash + run: | + # Define some variables for things we need + tag=$(git describe --tags --abbrev=0) + release_name="SmartTeslaAmpSetter-$tag-${{ matrix.target }}" + + # Build everything + dotnet publish SmartTeslaAmpSetter/Server/SmartTeslaAmpSetter.Server.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" + + # Pack files + tar czvf "${release_name}.tar.gz" "$release_name" + + # Delete output directory + rm -r "$release_name" + + - name: Build Plugins.SmaEnergymeter + shell: bash + run: | + # Define some variables for things we need + tag=$(git describe --tags --abbrev=0) + release_name="Plugins.SmaEnergymeter-$tag-${{ matrix.target }}" + + # Build everything + dotnet publish Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" + + # Pack files + tar czvf "${release_name}.tar.gz" "$release_name" + + # Delete output directory + rm -r "$release_name" + + - name: Publish + uses: softprops/action-gh-release@v1 + with: + files: "*.tar.gz" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + releaseDockerLatestSmartTeslaAmpSetter: + name: Building SmartTeslaAmpSetter image + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + # list of Docker images to use as base name for tags + images: | + pkuehnel/smartteslaampsetter + # generate Docker tags based on the following events/attributes + tags: | + type=semver,pattern={{version}} + + - name: Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: DockerHub login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASS}} + + - name: Build and push SmartTeslaAmpSetter + uses: docker/build-push-action@v2 + with: + file: ./SmartTeslaAmpSetter/Server/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + + releaseDockerLatestSmaEnergymeterplugin: + name: Building SMAPlugin Image + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + # list of Docker images to use as base name for tags + images: | + pkuehnel/smartteslaampsettersmaplugin + # generate Docker tags based on the following events/attributes + tags: | + type=semver,pattern={{version}} + + - name: Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: DockerHub login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASS}} + + - name: Build and push SmaPlugin + uses: docker/build-push-action@v2 + with: + file: ./Plugins.SmaEnergymeter/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/SmartTeslaAmpSetter/Server/.config/dotnet-tools.json b/SmartTeslaAmpSetter/Server/.config/dotnet-tools.json new file mode 100644 index 000000000..23f4f077a --- /dev/null +++ b/SmartTeslaAmpSetter/Server/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "6.0.3", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file