From 13c9497b67025343f96687acff25f471ec6941bf Mon Sep 17 00:00:00 2001 From: terasum Date: Sat, 16 Sep 2023 14:06:06 +0800 Subject: [PATCH] chore: workflow, build support windows and linux and mac --- .github/workflows/build-linux.yaml | 70 -------- .github/workflows/build-macos-x86_64.yaml | 127 -------------- .github/workflows/package-and-release.yaml | 186 +++++++++++++++++++++ 3 files changed, 186 insertions(+), 197 deletions(-) delete mode 100644 .github/workflows/build-linux.yaml delete mode 100644 .github/workflows/build-macos-x86_64.yaml create mode 100644 .github/workflows/package-and-release.yaml diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml deleted file mode 100644 index 2916383a..00000000 --- a/.github/workflows/build-linux.yaml +++ /dev/null @@ -1,70 +0,0 @@ -name: Build Medict Tasks -on: - push: -# tags: -# - v* - branches: - - master - - develop - -jobs: - package: - strategy: - matrix: - go-version: [1.21.x] - platform: [ubuntu-20.04] - runs-on: ${{ matrix.platform }} - steps: - - name: Get version tag (unix) - if: matrix.platform != 'windows-2019' - id: version - run: echo "::set-output name=tag::v-3.0.1-alpha-${GITHUB_SHA:0:6}" - - - name: Inall pnpm - uses: pnpm/action-setup@v2 - with: - version: 8.7.4 - run_install: false - - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - name: Chechout - uses: actions/checkout@v2 - - - name: Install Wails - run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - # linux - - name: Build for linux - if: matrix.platform == 'ubuntu-20.04' - run: | - sudo apt update && sudo apt install -y libgtk-3-dev libwebkit2gtk-4.0-dev - wails build -f -ldflags "-X main.Version=${{ steps.version.outputs.tag }}" - ls -lh $PWD && ls -lh $PWD/build - tar -C build/bin -zcvf Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz Medict - - - name: Upload linux tar.gz - if: matrix.platform == 'ubuntu-20.04' - uses: actions/upload-artifact@v2 - with: - name: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz - path: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz - - # - name: Create linux app image - # if: matrix.platform == 'ubuntu-16.04' - # run: | - # wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage - # chmod +x linuxdeploy-x86_64.AppImage - # mogrify -resize 512x512 appicon.png - # ./linuxdeploy*.AppImage --appdir AppDir --executable build/wombat --desktop-file AppImage.desktop --icon-file appicon.png --output appimage - # mv Wombat*.AppImage Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage - - # - name: Upload linux app image - # if: matrix.platform == 'ubuntu-16.04' - # uses: actions/upload-artifact@v2 - # with: - # name: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage - # path: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage \ No newline at end of file diff --git a/.github/workflows/build-macos-x86_64.yaml b/.github/workflows/build-macos-x86_64.yaml deleted file mode 100644 index 10907a53..00000000 --- a/.github/workflows/build-macos-x86_64.yaml +++ /dev/null @@ -1,127 +0,0 @@ -name: Build Medict Tasks -on: - push: -# tags: -# - v* - branches: - - master - - develop - -jobs: - package: - strategy: - matrix: - go-version: [1.21.x] - platform: [macos-latest] - runs-on: ${{ matrix.platform }} - steps: - - name: Get version tag (unix) - if: matrix.platform != 'windows-2019' - id: version - run: echo "::set-output name=tag::v-3.0.1-alpha-${GITHUB_SHA:0:6}" - - - name: Inall pnpm - uses: pnpm/action-setup@v2 - with: - version: 8.7.4 - run_install: false - - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - name: Chechout - uses: actions/checkout@v2 - - - name: Install Wails - run: go install github.com/wailsapp/wails/v2/cmd/wails@latest - - # darwin - - name: Build for darwin - if: matrix.platform == 'macos-latest' - run: | - wails build -f -ldflags "-X main.Version=${{ steps.version.outputs.tag }}" - - - name: Create darwin disk image - if: matrix.platform == 'macos-latest' - run: | - brew install create-dmg - ls -lh $PWD && ls -lh $PWD/build - create-dmg --volname "Medict" --volicon "build/assets/darwin/dmg_icon.icns" --background "build/assets/darwin/dmg_bg.png" --window-size 512 360 --icon-size 100 --icon "Medict.app" 100 185 --hide-extension "Medict.app" --app-drop-link 388 185 "Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg" "build/bin" - - - - name: Upload darwin disk image - if: matrix.platform == 'macos-latest' - uses: actions/upload-artifact@v2 - with: - name: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg - path: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg - - release: - runs-on: ubuntu-latest - needs: package - steps: - - name: Get version tag - id: version - # run: echo "::set-output name=tag::${GITHUB_REF/refs\/tags\//}" - run: echo "::set-output name=tag::v-3.0.1-alpha-${GITHUB_SHA:0:6}" - - - name: Get changelog url - id: changelog - run: echo "${{ steps.version.outputs.tag }}---$(date +'%Y-%m-%d')" | sed -e 's/\.//g' | awk '{print "::set-output name=url::https://github.com/terasum/medict/blob/develop/CHANGELOG.md#" $1}' - - - name: Create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.version.outputs.tag }} - release_name: ${{ steps.version.outputs.tag }} - body: "Medict Nightly build release:

${{ steps.version.outputs.tag }}

" - draft: true - prerelease: false - - - name: Download all release packages - uses: actions/download-artifact@v2 - - - name: Attach darwin disk image - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg/Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg - asset_name: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg - asset_content_type: application/octet-stream - -# - name: Attach linux tar.gz -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.create_release.outputs.upload_url }} -# asset_path: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz/Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz -# asset_name: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz -# asset_content_type: application/octet-stream - - # - name: Attach linux app image - # uses: actions/upload-release-asset@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # upload_url: ${{ steps.create_release.outputs.upload_url }} - # asset_path: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage/Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage - # asset_name: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage - # asset_content_type: application/octet-stream - -# - name: Attach windows zip -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.create_release.outputs.upload_url }} -# asset_path: Medict_${{ steps.version.outputs.tag }}_Windows_x86_64.zip/Medict_${{ steps.version.outputs.tag }}_Windows_x86_64.zip -# asset_name: Medict_${{ steps.version.outputs.tag }}_Windows_x86_64.zip -# asset_content_type: application/octet-stream \ No newline at end of file diff --git a/.github/workflows/package-and-release.yaml b/.github/workflows/package-and-release.yaml new file mode 100644 index 00000000..7299143c --- /dev/null +++ b/.github/workflows/package-and-release.yaml @@ -0,0 +1,186 @@ +name: Build Medict Tasks +on: + push: +# tags: +# - v* + branches: + - master + - develop + +jobs: + package: + strategy: + matrix: + go-version: [1.21.x] + platform: [macos-latest, ubuntu-20.04, windows-2019] + runs-on: ${{ matrix.platform }} + steps: + - name: Get version tag (unix) + if: matrix.platform != 'windows-2019' + id: version + run: echo "::set-output name=tag::v-3.0.1-alpha-${GITHUB_SHA:0:6}" + + - name: Get version tag (windows) + if: matrix.platform == 'windows-2019' + id: versionw + run: | + $tag = $env:GITHUB_SHA -replace "refs/tags/", "" + echo "::set-output name=tag::$(echo $tag)" + + - name: Inall pnpm + uses: pnpm/action-setup@v2 + with: + version: 8.7.4 + run_install: false + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Chechout + uses: actions/checkout@v2 + + - name: Install Wails + run: go install github.com/wailsapp/wails/v2/cmd/wails@latest + + # darwin + - name: Build for darwin + if: matrix.platform == 'macos-latest' + run: | + wails build -f -ldflags "-X main.Version=${{ steps.version.outputs.tag }}" + + - name: Create darwin disk image + if: matrix.platform == 'macos-latest' + run: | + brew install create-dmg + ls -lh $PWD && ls -lh $PWD/build + create-dmg --volname "Medict" --volicon "build/assets/darwin/dmg_icon.icns" --background "build/assets/darwin/dmg_bg.png" --window-size 512 360 --icon-size 100 --icon "Medict.app" 100 185 --hide-extension "Medict.app" --app-drop-link 388 185 "Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg" "build/bin" + + + - name: Upload darwin disk image + if: matrix.platform == 'macos-latest' + uses: actions/upload-artifact@v2 + with: + name: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg + path: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg + + # linux + - name: Build for linux + if: matrix.platform == 'ubuntu-20.04' + run: | + sudo apt update && sudo apt install -y libgtk-3-dev libwebkit2gtk-4.0-dev + wails build -f -ldflags "-X main.Version=${{ steps.version.outputs.tag }}" + ls -lh $PWD && ls -lh $PWD/build + tar -C build/bin -zcvf Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz Medict + + - name: Upload linux tar.gz + if: matrix.platform == 'ubuntu-20.04' + uses: actions/upload-artifact@v2 + with: + name: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz/Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz + path: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz + + # windows + - name: Build for windows + if: matrix.platform == 'windows-2019' + run: | + New-Item -ItemType directory -Path "$HOME\.wails" -Force + Copy-Item -Path "$PWD\wails.json" -Destination "$HOME\.wails\wails.json" + choco install mingw + wails build -f -ldflags "-X medict/internal/app.semver=${{ steps.versionw.outputs.tag }}" + Compress-Archive -Path "$PWD\build\medict.exe" -DestinationPath "$PWD\Medict_${{ steps.versionw.outputs.tag }}_Windows_x86_64.zip" + + - name: Upload windows zip + if: matrix.platform == 'windows-2019' + uses: actions/upload-artifact@v2 + with: + name: Medict_${{ steps.versionw.outputs.tag }}_Windows_x86_64.zip + path: Medict_${{ steps.versionw.outputs.tag }}_Windows_x86_64.zip + + + # - name: Create linux app image + # if: matrix.platform == 'ubuntu-16.04' + # run: | + # wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage + # chmod +x linuxdeploy-x86_64.AppImage + # mogrify -resize 512x512 appicon.png + # ./linuxdeploy*.AppImage --appdir AppDir --executable build/wombat --desktop-file AppImage.desktop --icon-file appicon.png --output appimage + # mv Wombat*.AppImage Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage + + # - name: Upload linux app image + # if: matrix.platform == 'ubuntu-16.04' + # uses: actions/upload-artifact@v2 + # with: + # name: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage + # path: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage + + + + release: + runs-on: ubuntu-latest + needs: package + steps: + - name: Get version tag + id: version + # run: echo "::set-output name=tag::${GITHUB_REF/refs\/tags\//}" + run: echo "::set-output name=tag::v-3.0.1-alpha-${GITHUB_SHA:0:6}" + + - name: Get changelog url + id: changelog + run: echo "${{ steps.version.outputs.tag }}---$(date +'%Y-%m-%d')" | sed -e 's/\.//g' | awk '{print "::set-output name=url::https://github.com/terasum/medict/blob/develop/CHANGELOG.md#" $1}' + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.tag }} + release_name: ${{ steps.version.outputs.tag }} + body: "Medict Nightly build release:

${{ steps.version.outputs.tag }}

" + draft: true + prerelease: false + + - name: Download all release packages + uses: actions/download-artifact@v2 + + - name: Attach darwin disk image + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg/Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg + asset_name: Medict_${{ steps.version.outputs.tag }}_Darwin_x86_64.dmg + asset_content_type: application/octet-stream + + - name: Attach linux tar.gz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz/Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz + asset_name: Medict_${{ steps.version.outputs.tag }}_Linux_x86_64.tar.gz + asset_content_type: application/octet-stream + + - name: Attach windows zip + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: Medict_${{ steps.version.outputs.tag }}_Windows_x86_64.zip/Medict_${{ steps.version.outputs.tag }}_Windows_x86_64.zip + asset_name: Medict_${{ steps.version.outputs.tag }}_Windows_x86_64.zip + asset_content_type: application/octet-stream + + # - name: Attach linux app image + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ steps.create_release.outputs.upload_url }} + # asset_path: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage/Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage + # asset_name: Wombat_${{ steps.version.outputs.tag }}_Linux_x86_64.AppImage + # asset_content_type: application/octet-stream