mirror of
https://github.com/bestnite/bilinovel-downloader.git
synced 2025-10-25 16:51:01 +00:00
feat: Add NFPM packaging and defer Playwright installation
This commit introduces NFPM configuration in `.goreleaser.yaml` to generate native packages for various Linux distributions (e.g., .deb, .rpm, .apk). This provides a more streamlined installation experience for Linux users. The Playwright browser installation logic has been moved from `main.go` to the `Run` function of the `download` command. This change ensures that Playwright binaries are only downloaded and installed when the `download` command is actually invoked, improving initial application startup performance and reducing unnecessary overhead for other commands. The Goreleaser configuration has also been updated to version 2 syntax and the `arm` architecture has been removed from builds.
This commit is contained in:
28
.github/workflows/release.yml
vendored
Normal file
28
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,3 +1,4 @@
|
||||
version: 2
|
||||
project_name: bilinovel-downloader
|
||||
before:
|
||||
hooks:
|
||||
@@ -12,16 +13,15 @@ builds:
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- arm
|
||||
- "386"
|
||||
ldflags:
|
||||
- -s -w -X bilinovel-downloader/cmd.Version={{ .Version }}
|
||||
flags:
|
||||
- -trimpath
|
||||
archives:
|
||||
- format: tar.gz
|
||||
- formats: ["tar.gz"]
|
||||
format_overrides:
|
||||
- format: zip
|
||||
- formats: ["zip"]
|
||||
goos: windows
|
||||
wrap_in_directory: true
|
||||
release:
|
||||
@@ -29,3 +29,17 @@ release:
|
||||
upx:
|
||||
- enabled: true
|
||||
compress: best
|
||||
|
||||
nfpms:
|
||||
- id: bilinovel-downloader
|
||||
homepage: https://github.com/bestnite/bilinovel-downloader
|
||||
maintainer: Nite <admin@nite07.com>
|
||||
license: "MIT"
|
||||
formats:
|
||||
- apk
|
||||
- deb
|
||||
- rpm
|
||||
- termux.deb
|
||||
- archlinux
|
||||
provides:
|
||||
- bilinovel-downloader
|
||||
|
||||
@@ -8,10 +8,12 @@ import (
|
||||
"bilinovel-downloader/text"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/playwright-community/playwright-go"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -20,7 +22,16 @@ var downloadCmd = &cobra.Command{
|
||||
Short: "Download a novel or volume",
|
||||
Long: "Download a novel or volume",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := runDownloadNovel()
|
||||
log.Println("Installing playwright")
|
||||
err := playwright.Install(&playwright.RunOptions{
|
||||
Browsers: []string{"chromium"},
|
||||
Stdout: io.Discard,
|
||||
})
|
||||
if err != nil {
|
||||
log.Panicf("failed to install playwright")
|
||||
}
|
||||
|
||||
err = runDownloadNovel()
|
||||
if err != nil {
|
||||
log.Printf("failed to download novel: %v", err)
|
||||
}
|
||||
|
||||
@@ -4,4 +4,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var RootCmd = &cobra.Command{}
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "bilinovel-downloader",
|
||||
}
|
||||
|
||||
12
main.go
12
main.go
@@ -2,20 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"bilinovel-downloader/cmd"
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"github.com/playwright-community/playwright-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("Installing playwright")
|
||||
err := playwright.Install(&playwright.RunOptions{
|
||||
Browsers: []string{"chromium"},
|
||||
Stdout: io.Discard,
|
||||
})
|
||||
if err != nil {
|
||||
log.Panicf("failed to install playwright")
|
||||
}
|
||||
_ = cmd.RootCmd.Execute()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user