Skip to content

Commit

Permalink
ci: migrate build process to Taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
bhunter234 committed Jan 14, 2025
1 parent 4c5d503 commit 9b25f3f
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 163 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
Expand Down
6 changes: 4 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ env:

before:
hooks:
- make frontend
- make gen
- task ui
- task gen

builds:
- env:
Expand Down Expand Up @@ -86,6 +86,8 @@ changelog:
exclude:
- '^README'
- '^Update'
- '^Version'
- '^ci:'
- Merge pull request
- Merge branch

Expand Down
24 changes: 0 additions & 24 deletions Dockerfile

This file was deleted.

137 changes: 0 additions & 137 deletions Makefile

This file was deleted.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/tgdrive/teldrive
go 1.23.3

require (
github.com/Masterminds/semver/v3 v3.3.1
github.com/WinterYukky/gorm-extra-clause-plugin v0.3.0
github.com/coocood/freecache v1.2.4
github.com/go-chi/chi/v5 v5.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7Oputl
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/WinterYukky/gorm-extra-clause-plugin v0.3.0 h1:fQfTkxoRso6mlm7eOfBIk94aqamJeqxCEfU+MyLWhgo=
github.com/WinterYukky/gorm-extra-clause-plugin v0.3.0/go.mod h1:GFT8TzxeeGKYXNU/65PsiN2+zNHigm9HjybnbL1T7eg=
github.com/beevik/ntp v1.4.3 h1:PlbTvE5NNy4QHmA4Mg57n7mcFTmr1W1j3gcK7L1lqho=
Expand Down
104 changes: 104 additions & 0 deletions scripts/extract.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//go:build ignore

package main

import (
"archive/zip"
"flag"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
)

func main() {
urlFlag := flag.String("url", "", "URL to download from")
outputFlag := flag.String("output", "", "Output directory")
flag.Parse()

if *urlFlag == "" || *outputFlag == "" {
flag.Usage()
os.Exit(1)
}

if err := os.RemoveAll(*outputFlag); err != nil {
fmt.Printf("Error removing directory: %v\n", err)
os.Exit(1)
}

if err := os.MkdirAll(*outputFlag, 0755); err != nil {
fmt.Printf("Error creating directory: %v\n", err)
os.Exit(1)
}

resp, err := http.Get(*urlFlag)
if err != nil {
fmt.Printf("Error downloading: %v\n", err)
os.Exit(1)
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
fmt.Printf("Bad status: %s\n", resp.Status)
os.Exit(1)
}

tmpFile, err := os.CreateTemp("", "download-*.zip")
if err != nil {
fmt.Printf("Error creating temp file: %v\n", err)
os.Exit(1)
}
defer os.Remove(tmpFile.Name())
defer tmpFile.Close()

_, err = io.Copy(tmpFile, resp.Body)
if err != nil {
fmt.Printf("Error saving download: %v\n", err)
os.Exit(1)
}

reader, err := zip.OpenReader(tmpFile.Name())
if err != nil {
fmt.Printf("Error opening zip: %v\n", err)
os.Exit(1)
}
defer reader.Close()

for _, file := range reader.File {
path := filepath.Join(*outputFlag, file.Name)

if file.FileInfo().IsDir() {
os.MkdirAll(path, os.ModePerm)
continue
}

if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
fmt.Printf("Error creating directory for file: %v\n", err)
os.Exit(1)
}

dstFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, file.Mode())
if err != nil {
fmt.Printf("Error creating file: %v\n", err)
os.Exit(1)
}

srcFile, err := file.Open()
if err != nil {
dstFile.Close()
fmt.Printf("Error opening zip entry: %v\n", err)
os.Exit(1)
}

_, err = io.Copy(dstFile, srcFile)
dstFile.Close()
srcFile.Close()
if err != nil {
fmt.Printf("Error extracting file: %v\n", err)
os.Exit(1)
}
}

fmt.Println("UI Extracted successfully!")
}
Loading

0 comments on commit 9b25f3f

Please sign in to comment.