From 294a8dd1ee6ab18a41caf8203b50340920513bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=91=D0=B0?= =?UTF-8?q?=D0=B4=D1=8F=D0=B5=D0=B2?= Date: Sat, 12 Oct 2024 15:06:01 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=BD=20workflow=20=D0=B8=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=81=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=BA=D0=B0=20MSI=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=D0=B0?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build.yaml | 58 +++++++++---- .gitea/workflows/release.yaml | 152 ++++++++++++++++++++++++++++------ makefile | 6 +- 3 files changed, 171 insertions(+), 45 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index c1cba62..166a782 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -10,8 +10,6 @@ on: jobs: build: runs-on: ubuntu-latest - # container: - # image: git.mousesoft.ru/ms/gitea-runner-images:python-ubuntu-latest steps: - name: check-out repository code uses: https://gitea.com/actions/checkout@v4 @@ -24,34 +22,62 @@ jobs: with: go-version: ">=1.22" - - name: test - run: make clean vendor lint test + - name: set-up dependencies + run: make clean vendor - - name: cache - uses: https://gitea.com/actions/cache@v4 - with: - path: | - out/*.tar.gz - key: ms_drawio-export_${{ github.sha }} + - name: test + run: make lint test - name: build amd64 binary - if: steps.cache.outputs.cache-hit != 'true' - run: GOARCH=amd64 make clean build + id: build-amd + run: | + echo "ARTIFACT=drawio-export-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT + GOARCH=amd64 make clean build - name: upload amd64 binary artifact uses: https://gitea.com/actions/upload-artifact@v3 with: - name: drawio-export-amd64 + name: ${{ steps.build-amd.outputs.ARTIFACT }} path: out/bin/* overwrite: true - name: build arm64 binary - if: steps.cache.outputs.cache-hit != 'true' - run: GOARCH=arm64 make clean build + id: build-arm + run: | + echo "ARTIFACT=drawio-export-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT + GOARCH=arm64 make clean build - name: upload arm64 binary artifact uses: https://gitea.com/actions/upload-artifact@v3 with: - name: drawio-export-arm64 + name: ${{ steps.build-arm.outputs.ARTIFACT }} + path: out/bin/* + overwrite: true + + build_windows: + runs-on: windows + defaults: + run: + shell: bash + steps: + - name: check-out repository code + uses: https://gitea.com/actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: set-up dependencies + run: make vendor + + - name: build + id: build + run: | + echo "ARTIFACT=drawio-export-$(make version)_$(go env GOOS)-$(go env GOARCH)" >> $GITHUB_OUTPUT + make build + + - name: upload artifact + uses: https://gitea.com/actions/upload-artifact@v3 + with: + name: ${{ steps.build.outputs.ARTIFACT }} path: out/bin/* overwrite: true diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 839e884..d7d8aaa 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -8,10 +8,11 @@ on: - "v*" jobs: - release: + build: runs-on: ubuntu-latest - # container: - # image: git.mousesoft.ru/ms/gitea-runner-images:python-ubuntu-latest + outputs: + artifact_amd64: ${{ steps.build-amd.outputs.ARTIFACT }} + artifact_arm64: ${{ steps.build-arm.outputs.ARTIFACT }} steps: - name: check-out repository code uses: https://gitea.com/actions/checkout@v4 @@ -24,26 +25,107 @@ jobs: with: go-version: ">=1.22" - - name: test - run: make clean vendor lint test + - name: set-up dependencies + run: make clean vendor - - name: cache - uses: https://gitea.com/actions/cache@v4 - with: - path: | - out/*.deb - out/*.changes - key: ms_drawio-export_pkg_${{ github.sha }} + - name: test + run: make lint test - name: build amd64 package - if: steps.cache.outputs.cache-hit != 'true' - run: GOARCH=amd64 make package + id: build-amd + run: | + echo "ARTIFACT=drawio-export-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT + GOARCH=amd64 make clean build package + + - name: upload amd64 package + uses: https://gitea.com/actions/upload-artifact@v3 + with: + name: ${{ steps.build-amd.outputs.ARTIFACT }} + path: | + out/*.changes + out/*.deb + overwrite: true - name: build arm64 package - if: steps.cache.outputs.cache-hit != 'true' - run: GOARCH=arm64 make package + id: build-arm + run: | + echo "ARTIFACT=drawio-export-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT + GOARCH=arm64 make clean build package - - name: deploy packages + - name: upload arm64 package + uses: https://gitea.com/actions/upload-artifact@v3 + with: + name: ${{ steps.build-arm.outputs.ARTIFACT }} + path: | + out/*.changes + out/*.deb + overwrite: true + + build_windows: + runs-on: windows + outputs: + artifact: ${{ steps.build.outputs.ARTIFACT }} + defaults: + run: + shell: bash + steps: + - name: check-out repository code + uses: https://gitea.com/actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: set-up dependencies + run: make vendor + + - name: build + id: build + run: | + echo "ARTIFACT=drawio-export-$(make version)_$(go env GOOS)-$(go env GOARCH)" >> $GITHUB_OUTPUT + make clean build package + + - name: upload artifact + uses: https://gitea.com/actions/upload-artifact@v3 + with: + name: ${{ steps.build.outputs.ARTIFACT }} + path: out/*.msi + overwrite: true + + deploy: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.meta.outputs.VERSION }} + changes: ${{ steps.meta.outputs.CHANGES }} + needs: + - build + steps: + - name: check-out repository code + uses: https://gitea.com/actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: get meta-data + id: meta + run: | + echo "VERSION=$(make version)" >> $GITHUB_OUTPUT + echo 'CHANGES<> $GITHUB_OUTPUT + gawk -f scripts/changes.awk -v version=$(make version-number) CHANGELOG.md >> $GITHUB_OUTPUT + echo EOF >> $GITHUB_OUTPUT + + - name: download debian amd64 package + uses: https://gitea.com/actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.artifact_amd64 }} + path: out/ + + - name: download debian ard64 package + uses: https://gitea.com/actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.artifact_arm64 }} + path: out/ + + - name: deploy debian packages env: SSH_HOST: ${{ secrets.DEB_SSH_HOST }} SSH_PORT: ${{ secrets.DEB_SSH_PORT }} @@ -65,21 +147,39 @@ jobs: cat ~/.ssh/config make deploy - - name: get meta-data - id: meta - run: | - echo "VERSION=$(make version)" >> $GITHUB_OUTPUT - echo 'CHANGES<> $GITHUB_OUTPUT - gawk -f scripts/changes.awk -v version=$(make version-number) CHANGELOG.md >> $GITHUB_OUTPUT - echo EOF >> $GITHUB_OUTPUT + release: + runs-on: ubuntu-latest + needs: + - build + - build_windows + - deploy + steps: + - name: download debian amd64 package + uses: https://gitea.com/actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.artifact_amd64 }} + path: out/ + + - name: download debian ard64 package + uses: https://gitea.com/actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.artifact_arm64 }} + path: out/ + + - name: download windows package + uses: https://gitea.com/actions/download-artifact@v4 + with: + name: ${{ needs.build_windows.outputs.artifact }} + path: out/ - name: release uses: https://gitea.com/actions/gitea-release-action@v1 with: - title: "MouseSoft DrawIO-Export ${{ steps.meta.outputs.VERSION }}" - body: "${{ steps.meta.outputs.CHANGES }}" + title: "MouseSoft DrawIO-Export ${{ needs.deploy.outputs.version }}" + body: "${{ needs.deploy.outputs.changes }}" files: | out/*.deb + out/*.msi sha256sum: true prerelease: true draft: true diff --git a/makefile b/makefile index 0d7a47f..b49b501 100644 --- a/makefile +++ b/makefile @@ -31,7 +31,7 @@ ECHO_CMD := echo ifeq ($(OS),Windows_NT) DIST_SUFFIX := windows-$(GOARCH) -MSI_FILE := $(PROJECT_ID)_$(VERSION)_$(GOARCH).msi +MSI_FILE ?= $(PROJECT_ID)_$(VERSION)_$(GOARCH).msi DIST_EXT := .zip DIST_OPTS := -a -cf ECHO_CMD := echo -e @@ -112,7 +112,7 @@ package: $(PACKAGE_TARGETS) ## Build all available packages .PHONY:package ifeq ($(OS),Windows_NT) -pkg-msi: build ## Create MSI package +pkg-msi: ## Create MSI package @rm -rf $(TMPDIR) @rm -f $(OUTDIR)/$(MSI_FILE) @mkdir -p $(TMPDIR) @@ -132,7 +132,7 @@ else DEB_NAME := $(PROJECT_ID)_$(VERSION_NUMBER)-1_$(GOARCH) -pkg-deb: build ## Build debian package +pkg-deb: ## Build debian package @rm -rf $(TMPDIR) @mkdir -p $(TMPDIR)/$(DEB_NAME)/usr/bin @mkdir -p $(TMPDIR)/$(DEB_NAME)/debian