Publish (GUI) #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish (GUI) | |
on: | |
workflow_dispatch: | |
inputs: | |
release_kind: | |
type: choice | |
description: The type of release. | |
default: prerelease | |
required: true | |
options: | |
- prerelease | |
- start-rc | |
- stable | |
jobs: | |
pre-build: | |
name: Update version name | |
runs-on: ubuntu-latest | |
outputs: | |
gui-version: ${{ env.GUI_VERSION }} | |
prerelease: ${{ steps.update-version.outputs.prerelease }} | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: anatawa12/something-releaser@v3 | |
- uses: snow-actions/git-config-user@v1.0.0 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Update Version Name | |
id: update-version | |
run: | | |
# set version name in properties file | |
case "$RELEASE_KIND_IN" in | |
"prerelease" ) | |
get-version -t gui | version-next | set-version -t gui | |
gh-export-variable PRERELEASE true | |
gh-set-output prerelease true | |
;; | |
"start-rc" ) | |
get-version -t gui | version-set-channel - rc 0 | set-version -t gui | |
gh-export-variable PRERELEASE true | |
gh-set-output prerelease true | |
;; | |
"stable" ) | |
get-version -t gui | version-set-channel - stable | set-version -t gui | |
gh-export-variable PRERELEASE false | |
gh-set-output prerelease '' # empty string for false | |
;; | |
* ) | |
echo "invalid release kind: $RELEASE_KIND_IN" | |
exit 255 | |
;; | |
esac | |
case "$GITHUB_REF_NAME" in | |
master | master-* ) | |
echo "head is master or master-*" | |
;; | |
* ) | |
echo "invalid release kind: $RELEASE_KIND_IN is not allowd for $GITHUB_REF_NAME" | |
exit 255 | |
;; | |
esac | |
gh-export-variable GUI_VERSION "$(get-version -t gui)" | |
env: | |
RELEASE_KIND_IN: ${{ github.event.inputs.release_kind }} | |
# region changelog | |
- name: Create Changelog | |
id: changelog | |
# if: ${{ !steps.update-version.outputs.prerelease }} | |
uses: anatawa12/sh-actions/changelog/prepare-release@master | |
with: | |
path: CHANGELOG-gui.md | |
version: ${{ env.GUI_VERSION }} | |
# use CHANGELOG-gui.md for all releases including beta for now | |
# there are several logics uses generated changelog, so remember to update them if you change this | |
prerelease: false # ${{ env.PRERELEASE }} | |
tag-prefix: gui-v | |
prerelease-note-heading: | | |
Version ${{ env.GUI_VERSION }} | |
--- | |
release-note-heading: | | |
Version ${{ env.GUI_VERSION }} | |
--- | |
- name: Upload CHANGELOG.md | |
# if: ${{ !steps.update-version.outputs.prerelease }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: CHANGELOG | |
path: CHANGELOG.md | |
- name: copy release note | |
# if: ${{ !steps.update-version.outputs.prerelease }} | |
run: cp "${{ steps.changelog.outputs.release-note }}" release-note.md | |
- name: Upload release note | |
# if: ${{ !steps.update-version.outputs.prerelease }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-note-for-release | |
path: release-note.md | |
- name: remove temp release note file | |
# if: ${{ !steps.update-version.outputs.prerelease }} | |
run: rm release-note.md | |
# endregion changelog | |
- name: Commit | |
id: update | |
run: |- | |
# commit & tag | |
git commit -am "gui v$GUI_VERSION" | |
git branch releasing | |
git push -f -u origin releasing | |
build-rust: | |
name: Build rust | |
environment: | |
name: actions-code-signing | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# note: when you changed paths for tauri updater (which are files with .sig), | |
# remember keep in sync with build-updater-json | |
- triple: x86_64-unknown-linux-gnu | |
on: ubuntu-latest | |
setup: | | |
sudo apt update && sudo apt install -y lld | |
ld.lld --version | |
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf | |
rustflags: "-C link-arg=-fuse-ld=lld" | |
dist-path: | | |
bundle/appimage/vrc-get-gui_${GUI_VERSION}_amd64.AppImage:vrc-get-gui-${GUI_VERSION}-x86_64.AppImage | |
bundle/appimage/vrc-get-gui_${GUI_VERSION}_amd64.AppImage.tar.gz:vrc-get-gui-${GUI_VERSION}-x86_64.AppImage.tar.gz | |
bundle/appimage/vrc-get-gui_${GUI_VERSION}_amd64.AppImage.tar.gz.sig:vrc-get-gui-${GUI_VERSION}-x86_64.AppImage.tar.gz.sig | |
- triple: x86_64-pc-windows-msvc | |
on: windows-latest | |
dist-path: | | |
vrc-get-gui.exe:vrc-get-gui-${GUI_VERSION}-x86_64.exe | |
bundle/nsis/vrc-get-gui_${GUI_VERSION}_x64-setup.exe:vrc-get-gui-${GUI_VERSION}-x86_64-setup.exe | |
bundle/nsis/vrc-get-gui_${GUI_VERSION}_x64-setup.nsis.zip:vrc-get-gui-${GUI_VERSION}-x86_64-setup.nsis.zip | |
bundle/nsis/vrc-get-gui_${GUI_VERSION}_x64-setup.nsis.zip.sig:vrc-get-gui-${GUI_VERSION}-x86_64-setup.nsis.zip.sig | |
- triple: universal-apple-darwin | |
on: macos-14 | |
setup: | | |
rustup target add aarch64-apple-darwin | |
rustup target add x86_64-apple-darwin | |
dist-path: | | |
bundle/dmg/vrc-get-gui_${GUI_VERSION}_universal.dmg:vrc-get-gui-${GUI_VERSION}-universal.dmg | |
bundle/macos/vrc-get-gui.app.tar.gz:bundle/macos/vrc-get-gui-${GUI_VERSION}-universal.app.tar.gz | |
bundle/macos/vrc-get-gui.app.tar.gz:bundle/macos/vrc-get-gui-${GUI_VERSION}-universal.app.tar.gz.sig | |
triple: | |
- x86_64-unknown-linux-gnu | |
#- aarch64-unknown-linux-musl | |
- x86_64-pc-windows-msvc | |
#- aarch64-pc-windows-msvc | |
- universal-apple-darwin | |
runs-on: ${{ matrix.on }} | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
needs: [ pre-build ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'releasing' | |
submodules: recursive | |
- name: Install cross-compilation tools | |
uses: taiki-e/setup-cross-toolchain-action@v1 | |
if: ${{ matrix.triple != 'universal-apple-darwin' }} | |
with: | |
target: ${{ matrix.triple }} | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-targets: false # for release build, do not cache build artifacts | |
key: release-gui # there are no elements about build result, so it's ok to share between all builds | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-about | |
- name: Setup | |
run: ${{ matrix.setup }} | |
- uses: tauri-apps/tauri-action@v0 | |
env: | |
# apple code signing | |
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} | |
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }} | |
APPLE_ID: ${{ secrets.APPLE_ID }} | |
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
# tauri updater signing | |
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | |
with: | |
projectPath: vrc-get-gui | |
tauriScript: npm run tauri | |
args: --target ${{ matrix.triple }} | |
- name: Move artifacts | |
shell: bash | |
env: | |
GUI_VERSION: ${{ needs.pre-build.outputs.gui-version }} | |
DIST_PATH: ${{ matrix.dist-path }} | |
run: |- | |
mkdir artifacts | |
echo "$DIST_PATH" | while IFS=: read -r src dst; do | |
src="${src//\$\{GUI_VERSION\}/$GUI_VERSION}" | |
dst="${dst//\$\{GUI_VERSION\}/$GUI_VERSION}" | |
if [ -z "$dst" ]; then | |
continue | |
fi | |
printf "mv %s %s\n" "target/${{ matrix.triple }}/release/$src" "artifacts/$dst" | |
mv "target/${{ matrix.triple }}/release/$src" "artifacts/$dst" | |
done | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{ matrix.triple }} | |
path: artifacts/* | |
build-updater-json: | |
runs-on: ubuntu-latest | |
needs: [ pre-build, build-rust ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'releasing' | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: assets | |
pattern: artifacts-* | |
merge-multiple: true | |
- name: Run updater-json | |
env: | |
GUI_VERSION: ${{ needs.pre-build.outputs.gui-version }} | |
run: cargo run -p build-updater-json | |
- name: Upload updater-json | |
uses: actions/upload-artifact@v4 | |
with: | |
name: updater.json | |
path: updater.json | |
publish-to-github: | |
name: Publish to GitHub | |
environment: | |
name: actions-github-app | |
url: https://github.com/anatawa12/vrc-get/releases/gui-v${{ needs.pre-build.outputs.gui-version }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: [ pre-build, build-rust, build-updater-json ] | |
env: | |
GUI_VERSION: ${{ needs.pre-build.outputs.gui-version }} | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'releasing' | |
fetch-depth: 2 | |
submodules: recursive | |
token: ${{ steps.app-token.outputs.token }} | |
# tools | |
- uses: anatawa12/something-releaser@v3 | |
- uses: snow-actions/git-config-user@v1.0.0 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: assets | |
pattern: artifacts-* | |
merge-multiple: true | |
- name: Download changelog | |
# if: ${{ !needs.pre-build.outputs.prerelease }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-note-for-release | |
path: changelog | |
- name: Push tag | |
run: |- | |
# set tag and publish current version | |
git tag "gui-v$GUI_VERSION" | |
git push --tags | |
# create master and push | |
git switch -c master | |
git fetch origin master --depth=1 | |
git log --all --graph | |
git push -u origin master | |
sleep 1 | |
- name: create release | |
shell: bash | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: |- | |
# Always prerelease for now. | |
# always generating notes file for now | |
# ${{ !needs.pre-build.outputs.prerelease && '--notes-file changelog/release-note.md' || '' }} \ | |
gh release create \ | |
--prerelease \ | |
--latest=false \ | |
--notes-file changelog/release-note.md \ | |
--verify-tag "gui-v$GUI_VERSION" \ | |
assets/* | |
rm -rf outputs assets | |
- name: prepare next release & push | |
if: ${{ !needs.pre-build.outputs.prerelease }} | |
run: | | |
get-version -t gui | version-next | version-set-channel - beta 0 | set-version -t gui | |
GUI_NEXT="$(get-version -t gui | version-stable)" | |
git commit -am "chore: prepare for next version: gui $GUI_NEXT" | |
git push | |
cleanup: | |
name: Cleanup | |
if: ${{ !failure() && !cancelled() }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: | |
- pre-build | |
- build-rust | |
- publish-to-github | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'releasing' | |
fetch-depth: 2 | |
- name: remove releasing branch | |
run: git push --delete origin releasing | |
pull-request-to-website: | |
name: Create PullRequest to vrc-get.anatawa12.com for updater.json | |
runs-on: ubuntu-latest | |
needs: [ publish-to-github, build-updater-json ] | |
env: | |
GUI_VERSION: ${{ needs.pre-build.outputs.gui-version }} | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
repository: 'vrc-get/vrc-get.anatawa12.com' | |
ref: 'master' | |
token: ${{ steps.app-token.outputs.token }} | |
- uses: snow-actions/git-config-user@v1.0.0 | |
- name: Download updater.json | |
uses: actions/download-artifact@v4 | |
with: | |
name: updater.json | |
path: . | |
- name: Move updater.json | |
run: | | |
mkdir -p api/gui | |
mv updater.json public/api/gui/tauri-updater.json | |
- name: Commit | |
run: |- | |
BRANCH_NAME="update-tauri-updater-json-v$GUI_VERSION" | |
git switch -c "$BRANCH_NAME" | |
git add public/api/gui/tauri-updater.json | |
git commit -m "chore: update tauri-updater.json to v$GUI_VERSION" | |
git push -u origin "$BRANCH_NAME" | |
- name: Create Pull Request | |
run: | | |
BRANCH_NAME="update-tauri-updater-json-v$GUI_VERSION" | |
gh pr create \ | |
--title "chore: update tauri-updater.json to v$GUI_VERSION" \ | |
--body "update tauri-updater.json to v$GUI_VERSION" \ | |
--base master \ | |
--head "$BRANCH_NAME" \ | |
--assignee anatawa12 \ |