Skip to content

Commit

Permalink
改进 Sillot CI/CD 工作流 #655
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Apr 25, 2024
1 parent 1145cea commit 84e7886
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
60 changes: 30 additions & 30 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ jobs:
run: |
echo "release_title=$(git show --format=%s --no-patch | head -1)" >> $GITHUB_OUTPUT
echo "release_version=v${{ steps.version.outputs.value }}_$(TZ=Asia/Shanghai date +'%Y%m%d')_syv${{ steps.syv.outputs.value }}" >> $GITHUB_OUTPUT
changelog1=$(python scripts/parse-changelog-HEAD.py -t ${{ github.ref }} -b ${{ steps.thisLatestRelease.outputs.release }} ${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }})
changelog2=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} ${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }})
changelog3=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} ${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name_android }})
changelog1=$(python scripts/parse-changelog-HEAD.py -t ${{ github.ref }} -b ${{ steps.thisLatestRelease.outputs.release }} $repo_owner/$repo_name)
changelog2=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} $repo_owner/$repo_name)
changelog3=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} $repo_owner/${{ matrix.string.repo_name_android }})
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "release_body_sillot<<$EOF" >> $GITHUB_ENV
echo "$changelog1" >> $GITHUB_ENV
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}
path: ${{ github.workspace }}/$repo_owner/$repo_name

- name: Set up MingGW
uses: msys2/setup-msys2@v2
Expand All @@ -188,20 +188,20 @@ jobs:
install: p7zip mingw-w64-x86_64-lua

- name: Set up TDM-GCC
run: msys2 -c "bash ${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/scripts/get-tdm-gcc.sh tdm https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm-1/tdm-gcc-10.3.0.exe" && echo "CC=${{ github.workspace }}/tdm/bin/gcc.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
run: msys2 -c "bash $repo_owner/$repo_name/scripts/get-tdm-gcc.sh tdm https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm-1/tdm-gcc-10.3.0.exe" && echo "CC=${{ github.workspace }}/tdm/bin/gcc.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if: contains( matrix.config.goarch, '386')
working-directory: ${{ github.workspace }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/kernel/go.mod
go-version-file: ${{ github.workspace }}/$repo_owner/$repo_name/kernel/go.mod
- run: go version

- name: Set up goversioninfo
run: go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo && go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo
if: contains( matrix.config.goos, 'windows')
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/kernel
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/kernel
env:
GO111MODULE: on
CGO_ENABLED: 1
Expand All @@ -216,46 +216,46 @@ jobs:

- name: Install Node pnpm
run: npm install -g ${{ needs.create_release.outputs.packageManager }}
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/app

- name: Change NPMRC File
run: pnpm config set registry https://registry.npmjs.org/ --location project
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/app
- name: Install Node Dependencies
run: ${{ needs.create_release.outputs.actionInstallCommand }}
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/app

- name: Building UI
run: pnpm run build
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/app

- name: Remove Build Directory
uses: K-Sillot/rm@master
if: ${{ !contains( matrix.config.suffix, 'apk') }}
with:
path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app/build
path: ${{ github.workspace }}/$repo_owner/$repo_name/app/build

- name: Remove Kernel Directory for Linux
uses: K-Sillot/rm@master
if: ${{ !contains( matrix.config.suffix, 'apk') }}
with:
path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app/kernel-linux
path: ${{ github.workspace }}/$repo_owner/$repo_name/app/kernel-linux

- name: Remove Kernel Directory for Windows
uses: K-Sillot/rm@master
if: ${{ !contains( matrix.config.suffix, 'apk') }}
with:
path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app/kernel
path: ${{ github.workspace }}/$repo_owner/$repo_name/app/kernel

- name: Generate Icon Resource and Properties/Version Info For Windows
run: ${{ github.workspace }}\go\${{ matrix.config.gobin }}\goversioninfo -platform-specific=true -icon="resource\icon.ico" -manifest="resource\goversioninfo.exe.manifest"
if: ${{ contains( matrix.config.goos, 'windows') && !contains( matrix.config.suffix, 'apk') }}
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/kernel
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/kernel

- name: Building Kernel
if: ${{ !contains( matrix.config.suffix, 'apk') }}
run: go build --tags fts5 -o "${{ matrix.config.kernel_path }}" -v -ldflags "${{ matrix.config.build_args }}"
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/kernel
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/kernel
env:
GO111MODULE: on
CGO_ENABLED: 1
Expand All @@ -266,7 +266,7 @@ jobs:
- name: Building Electron
if: ${{ !contains( matrix.config.suffix, 'apk') }}
run: pnpm run ${{ matrix.config.electron_args }}
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app
working-directory: ${{ github.workspace }}/$repo_owner/$repo_name/app

- name: Upload Release Asset for Windows & Linux
if: ${{ !contains( matrix.config.suffix, 'apk') }}
Expand All @@ -275,16 +275,16 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ${{ matrix.string.repo_name }}-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }}
asset_path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app/build/${{ matrix.string.repo_name }}-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}
asset_name: $repo_name-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }}
asset_path: ${{ github.workspace }}/$repo_owner/$repo_name/app/build/$repo_name-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}

- name: zip WinPortable
uses: thedoctor0/zip-release@0.7.1
if: ${{ contains( matrix.config.goos, 'windows') && !contains( matrix.config.suffix, 'apk') }}
with:
type: 'zip'
filename: ${{ matrix.string.repo_name }}-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}/app/build/win-unpacked/
filename: $repo_name-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
path: ${{ github.workspace }}/$repo_owner/$repo_name/app/build/win-unpacked/
exclusions: '*.git*'
recursive_exclusions: 'LICENSES.chromium.html'

Expand All @@ -295,8 +295,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ${{ matrix.string.repo_name }}-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
asset_path: ${{ matrix.string.repo_name }}-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
asset_name: $repo_name-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
asset_path: $repo_name-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip


# Manual setup is required when the built-in version does not work correctly in windows2022
Expand All @@ -321,25 +321,25 @@ jobs:
uses: K-Sillot/rm@master
if: contains( matrix.config.suffix, 'apk')
with:
path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name_android }}
path: ${{ github.workspace }}/$repo_owner/${{ matrix.string.repo_name_android }}

- name: Checkout android repo
uses: actions/checkout@v4
if: contains( matrix.config.suffix, 'apk')
with:
repository: ${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name_android }}
path: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name_android }}
repository: $repo_owner/${{ matrix.string.repo_name_android }}
path: ${{ github.workspace }}/$repo_owner/${{ matrix.string.repo_name_android }}

- name: Before android build
if: contains( matrix.config.suffix, 'apk')
run: |
cd ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name }}
cd ${{ github.workspace }}/$repo_owner/$repo_name
.\scripts\sillot-android-build-action.bat
continue-on-error: false

- name: Build with Gradle
if: contains( matrix.config.suffix, 'apk')
working-directory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name_android }}
working-directory: ${{ github.workspace }}/$repo_owner/${{ matrix.string.repo_name_android }}
run: ./gradlew assembleOfficialAction --quiet --stacktrace
continue-on-error: false

Expand All @@ -348,7 +348,7 @@ jobs:
name: Sign APK
id: sign_app
with:
releaseDirectory: ${{ github.workspace }}/${{ matrix.string.repo_owner }}/${{ matrix.string.repo_name_android }}/app/build/outputs/apk/official/action
releaseDirectory: ${{ github.workspace }}/$repo_owner/${{ matrix.string.repo_name_android }}/app/build/outputs/apk/official/action
signingKeyBase64: ${{ secrets.APK_SIGN_KEY_JKS_BASE64 }}
alias: ${{ secrets.APK_SIGN_KEY_ALIAS }}
keyStorePassword: ${{ secrets.APK_SIGN_KEY_JKS_PW }}
Expand All @@ -364,7 +364,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ${{ matrix.string.repo_name }}-${{ needs.create_release.outputs.release_version }}-beta_github.apk
asset_name: $repo_name-${{ needs.create_release.outputs.release_version }}-beta_github.apk
asset_path: ${{steps.sign_app.outputs.signedReleaseFile}}

- name: Upload logs if failure
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sillot",
"version": "0.31.1760",
"version": "0.31.1770",
"syv": "3.0.12",
"sypv": "[]",
"description": "Build Your Eternal Digital Garden",
Expand Down

0 comments on commit 84e7886

Please sign in to comment.