Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安定版リリースをHomebrewでインストールできるようにする #2

Merged
merged 2 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
298 changes: 298 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
# Copyright © 2013, Paul Hinze & Contributors, Umi
umi1299 marked this conversation as resolved.
Show resolved Hide resolved
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


name: CI

on:
pull_request:
paths-ignore:
- Casks/*-preview.rb

env:
HOMEBREW_DEVELOPER: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_FROM_API: 1
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }}

concurrency:
group: "${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

jobs:
generate-matrix:
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
runs-on: macos-latest
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: false
cask: true
test-bot: false

- name: Check out Pull Request
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Generate CI matrix
id: generate-matrix
run: |
brew ruby -- "$(brew --repository homebrew/cask)/cmd/lib/generate-matrix.rb" "${{ github.event.pull_request.url }}"

test:
name: ${{ matrix.name }}
needs: generate-matrix
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: false
cask: true
test-bot: false

- name: Enable debug mode
run: |
echo 'HOMEBREW_DEBUG=1' >> "${GITHUB_ENV}"
echo 'HOMEBREW_VERBOSE=1' >> "${GITHUB_ENV}"
if: runner.debug

- name: Check out Pull Request
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Clean up CI machine
run: |
if ! brew list --cask visual-studio &>/dev/null; then
if ! rm -r '/Applications/Visual Studio.app'; then
echo '::warning::Removing Visual Studio is no longer necessary.'
fi
fi

if ! brew uninstall --cask julia && ! rm -r /Applications/Julia-*.app; then
echo '::warning::Removing Julia is no longer necessary.'
fi

if ! rm /usr/local/bin/dotnet; then
echo '::warning::Removing `dotnet` symlink is no longer necessary.'
fi

if ! rm /usr/local/bin/pod; then
echo '::warning::Removing `cocoapods` symlink is no longer necessary.'
fi

brew unlink python && brew link --overwrite python
if: runner.os == 'macOS'

- name: Cache Homebrew Gems
id: cache
uses: actions/cache@v3
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ matrix.runner }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ matrix.runner }}-rubygems-

- name: Install Homebrew Gems
id: gems
run: brew install-bundler-gems
if: steps.cache.outputs.cache-hit != 'true'

- name: Run brew readall ${{ matrix.tap }}
id: readall
run: brew readall '${{ matrix.tap }}'
if: >
always() &&
contains(fromJSON('["success", "skipped"]'), steps.gems.outcome) &&
!matrix.skip_readall

- name: Run brew style ${{ matrix.tap }}
run: brew style '${{ matrix.tap }}'
if: >
always() &&
contains(fromJSON('["success", "skipped"]'), steps.readall.outcome) &&
!matrix.cask

- name: Run brew fetch --cask ${{ matrix.cask.token }}
id: fetch
run: |
brew fetch --cask --retry --force ${{ join(matrix.fetch_args, ' ') }} '${{ matrix.cask.path }}'
timeout-minutes: 30
if: >
always() &&
contains(fromJSON('["success", "skipped"]'), steps.readall.outcome) &&
matrix.cask

- name: Run brew audit --cask${{ (matrix.cask && ' ') || ' --tap ' }}${{ matrix.cask.token || matrix.tap }}
id: audit
run: |
brew audit --cask ${{ join(matrix.audit_args, ' ') }}${{ (matrix.cask && ' ') || ' --tap ' }}'${{ matrix.cask.token || matrix.tap }}'
timeout-minutes: 30
if: >
always() &&
contains(fromJSON('["success", "skipped"]'), steps.readall.outcome) &&
(!matrix.cask || steps.fetch.outcome == 'success') &&
!matrix.skip_audit

- name: Gather cask information
id: info
run: |
brew tap homebrew/cask-versions
brew ruby <<'EOF'
require 'cask/cask_loader'
require 'cask/installer'

cask = Cask::CaskLoader.load('${{ matrix.cask.path }}')

was_installed = cask.installed?
manual_installer = cask.artifacts.any? { |artifact|
artifact.is_a?(Cask::Artifact::Installer::ManualInstaller)
}

macos_requirement_satisfied = if macos_requirement = cask.depends_on.macos
macos_requirement.satisfied?
else
true
end

cask_conflicts = cask.conflicts_with&.dig(:cask).to_a.select { |c| Cask::CaskLoader.load(c).installed? }
formula_conflicts = cask.conflicts_with&.dig(:formula).to_a.select { |f| Formula[f].any_version_installed? }

installer = Cask::Installer.new(cask)
cask_and_formula_dependencies = installer.missing_cask_and_formula_dependencies

cask_dependencies = cask_and_formula_dependencies.select { |d| d.is_a?(Cask::Cask) }.map(&:full_name)
formula_dependencies = cask_and_formula_dependencies.select { |d| d.is_a?(Formula) }.map(&:full_name)

File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
f.puts "was_installed=#{JSON.generate(was_installed)}"
f.puts "manual_installer=#{JSON.generate(manual_installer)}"
f.puts "macos_requirement_satisfied=#{JSON.generate(macos_requirement_satisfied)}"
f.puts "cask_conflicts=#{JSON.generate(cask_conflicts)}"
f.puts "cask_dependencies=#{JSON.generate(cask_dependencies)}"
f.puts "formula_conflicts=#{JSON.generate(formula_conflicts)}"
f.puts "formula_dependencies=#{JSON.generate(formula_dependencies)}"
end
EOF
if: always() && steps.fetch.outcome == 'success' && matrix.cask

- name: Uninstall conflicting formulae
run: |
brew uninstall --formula ${{ join(fromJSON(steps.info.outputs.formula_conflicts), ' ') }}
if: always() && steps.info.outcome == 'success' && join(fromJSON(steps.info.outputs.formula_conflicts)) != ''
timeout-minutes: 30

- name: Uninstall conflicting casks
run: |
brew uninstall --cask ${{ join(fromJSON(steps.info.outputs.cask_conflicts), ' ') }}
if: always() && steps.info.outcome == 'success' && join(fromJSON(steps.info.outputs.cask_conflicts)) != ''
timeout-minutes: 30

- name: Run brew uninstall --cask --zap ${{ matrix.cask.token }}
run: |
brew uninstall --cask --zap '${{ matrix.cask.path }}'
if: always() && steps.info.outcome == 'success' && fromJSON(steps.info.outputs.was_installed)
timeout-minutes: 30

- name: Take snapshot of installed and running apps and services
id: snapshot
run: |
brew ruby -r "$(brew --repository homebrew/cask)/cmd/lib/check.rb" <<'EOF'
File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
f.puts "before=#{JSON.generate(Check.all)}"
end
EOF
if: always() && steps.info.outcome == 'success'

- name: Run brew install --cask ${{ matrix.cask.token }}
id: install
run: brew install --cask '${{ matrix.cask.path }}'
if: >
always() && steps.info.outcome == 'success' &&
fromJSON(steps.info.outputs.macos_requirement_satisfied) &&
!matrix.skip_install
timeout-minutes: 30

- name: Run brew uninstall --cask ${{ matrix.cask.token }}
run: brew uninstall --cask '${{ matrix.cask.path }}'
if: always() && steps.install.outcome == 'success' && !fromJSON(steps.info.outputs.manual_installer)
timeout-minutes: 30

- name: Uninstall formula dependencies
run: |
brew uninstall --formula ${{ join(fromJSON(steps.info.outputs.formula_dependencies), ' ') }}
if: always() && steps.install.outcome == 'success' && join(fromJSON(steps.info.outputs.formula_dependencies)) != ''
timeout-minutes: 30

- name: Uninstall cask dependencies
run: |
brew uninstall --cask ${{ join(fromJSON(steps.info.outputs.cask_dependencies), ' ') }}
if: always() && steps.install.outcome == 'success' && join(fromJSON(steps.info.outputs.cask_dependencies)) != ''
timeout-minutes: 30

- name: Compare installed and running apps and services with snapshot
run: |
brew ruby -r "$(brew --repository homebrew/cask)/cmd/lib/check.rb" <<'EOF'
require "cask/cask_loader"
require "utils/github/actions"

before = JSON.parse(<<~'EOS').transform_keys(&:to_sym)
${{ steps.snapshot.outputs.before }}
EOS
after = Check.all

cask = Cask::CaskLoader.load('${{ matrix.cask.path }}')
errors = Check.errors(before, after, cask: cask)

errors.each do |error|
onoe error
puts GitHub::Actions::Annotation.new(:error, error, file: '${{ matrix.cask.path }}')
end

exit 1 if errors.any?
EOF
if: always() && steps.snapshot.outcome == 'success'

conclusion:
name: conclusion
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- name: Result
run: ${{ needs.test.result == 'success' }}
28 changes: 28 additions & 0 deletions Casks/voicevox.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cask "voicevox" do
version "0.14.7"
sha256 "341df00cced9f8b516dda4e79902d4106a34f89dc18264cb1bb6a5721282d75c"

url "https://github.com/VOICEVOX/voicevox/releases/download/#{version}/VOICEVOX.#{version}.dmg",
verified: "github.com/VOICEVOX/voicevox/"
name "VOICEVOX"
desc "Free, medium-quality text-to-speech software"
homepage "https://voicevox.hiroshiba.jp/"

livecheck do
url :url
strategy :github_latest
end

conflicts_with cask: "voicevox-preview"

app "VOICEVOX.app"

zap trash: [
"~/Library/Application Support/voicevox",
"~/Library/Application Support/voicevox-cpu",
"~/Library/Application Support/voicevox-engine",
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
"~/Library/Logs/voicevox-cpu",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

次辺りにディレクトリが増える("変わる"じゃなく"増える"なのは不具合ですが。。)ので追加しちゃいましょう!

Suggested change
"~/Library/Logs/voicevox-cpu",
"~/Library/Logs/voicevox",
"~/Library/Logs/voicevox-cpu",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

次のリリースのときに追加するPRを出そうと思います! (ここをActionsで自動更新させるのは難しそうですね…)

"~/Library/Preferences/jp.hiroshiba.voicevox.plist",
"~/Library/Saved Application State/jp.hiroshiba.voicevox.savedState",
]
end
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# homebrew-voicevox

HomebrewでVOICEVOXをインストールできるようにするリポジトリです。

## インストール方法

```sh
$ brew tap VOICEVOX/voicevox
$ brew install --cask --no-quarantine voicevox
```