mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Redo how the distribution artifact is created
- Add version information to the stitching tool
This commit is contained in:
parent
729cc50539
commit
af890f4df1
29
.github/workflows/build-release.yml
vendored
29
.github/workflows/build-release.yml
vendored
@ -12,15 +12,28 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
goos: [windows]
|
goos: [windows]
|
||||||
goarch: [amd64]
|
goarch: ["386"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.18
|
||||||
|
|
||||||
- uses: wangyoucao577/go-release-action@master
|
- name: Check out code into the Go module directory
|
||||||
with:
|
uses: actions/checkout@v2
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
goos: ${{ matrix.goos }}
|
- name: Build stitch tool
|
||||||
goarch: ${{ matrix.goarch }}
|
run: go build -v -ldflags="-X 'main.versionString=${{ github.event.release.tag_name }}'" .
|
||||||
extra_files: init.lua LICENSE compatibility.xml mod.xml README.md AREAS.md images/coordinates.png images/example1.png images/example2.png images/scale32_base-layout.png images/scale32_main-world.png images/scale32_extended.png data files capture-b/capture.dll capture-b/README.md stitch/stitch.exe stitch/README.md
|
working-directory: ./bin/stitch
|
||||||
|
|
||||||
|
- name: Create distribution archive
|
||||||
|
run: go run -v ./scripts/dist
|
||||||
|
|
||||||
|
- name: Upload binary to release
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
file: dist/dist.zip
|
||||||
|
asset_name: noita-mapcap-${{ matrix.goos }}-${{ matrix.goarch }}.zip
|
||||||
|
overwrite: true
|
||||||
|
13
.github/workflows/build-test.yml
vendored
13
.github/workflows/build-test.yml
vendored
@ -9,17 +9,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.18
|
go-version: ^1.18
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Build
|
- name: Build stitch tool
|
||||||
run: go build -v ./bin/stitch
|
run: go build -v .
|
||||||
|
working-directory: ./bin/stitch
|
||||||
|
|
||||||
- name: Test
|
- name: Test stitch tool
|
||||||
run: go test -v ./bin/stitch
|
run: go test -v .
|
||||||
|
working-directory: ./bin/stitch
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -103,7 +103,6 @@ $RECYCLE.BIN/
|
|||||||
|
|
||||||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
||||||
|
|
||||||
/libs/
|
|
||||||
/output/
|
/output/
|
||||||
/distribution/
|
/dist/
|
||||||
/bin/stitch/output.png
|
/bin/stitch/output.png
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -7,11 +7,13 @@
|
|||||||
"downscaling",
|
"downscaling",
|
||||||
"executables",
|
"executables",
|
||||||
"Fullscreen",
|
"Fullscreen",
|
||||||
|
"goarch",
|
||||||
"gridify",
|
"gridify",
|
||||||
"hacky",
|
"hacky",
|
||||||
"hilbertify",
|
"hilbertify",
|
||||||
"kbinani",
|
"kbinani",
|
||||||
"Lanczos",
|
"Lanczos",
|
||||||
|
"ldflags",
|
||||||
"lowram",
|
"lowram",
|
||||||
"manifoldco",
|
"manifoldco",
|
||||||
"mapcap",
|
"mapcap",
|
||||||
@ -20,6 +22,7 @@
|
|||||||
"prerender",
|
"prerender",
|
||||||
"promptui",
|
"promptui",
|
||||||
"schollz",
|
"schollz",
|
||||||
|
"svenstaro",
|
||||||
"tcnksm",
|
"tcnksm",
|
||||||
"Vogel",
|
"Vogel",
|
||||||
"xmax",
|
"xmax",
|
||||||
|
@ -31,6 +31,8 @@ var flagPrerender = flag.Bool("prerender", false, "Pre renders the image in RAM
|
|||||||
var flagCleanupThreshold = flag.Float64("cleanup", 0, "Enable cleanup mode with the given threshold. This will DELETE images from the input folder, no stitching will be done in this mode. A good value to start with is 0.999, which deletes images where the sum of the min-max difference of each sub-pixel overlapping with other images is less than 99.9%% of the maximum possible sum of pixel differences.")
|
var flagCleanupThreshold = flag.Float64("cleanup", 0, "Enable cleanup mode with the given threshold. This will DELETE images from the input folder, no stitching will be done in this mode. A good value to start with is 0.999, which deletes images where the sum of the min-max difference of each sub-pixel overlapping with other images is less than 99.9%% of the maximum possible sum of pixel differences.")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
log.Printf("Noita MapCapture stitching tool v%s", version)
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// Query the user, if there were no cmd arguments given
|
// Query the user, if there were no cmd arguments given
|
||||||
|
29
bin/stitch/version.go
Normal file
29
bin/stitch/version.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2022 David Vogel
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/coreos/go-semver/semver"
|
||||||
|
)
|
||||||
|
|
||||||
|
// versionString contains the semantic version of the software as a string.
|
||||||
|
//
|
||||||
|
// This variable is only used to transfer the correct version information into the build.
|
||||||
|
// Don't use this variable in the software, use `version` instead.
|
||||||
|
//
|
||||||
|
// When building the software, the default `v0.0.0-development` is used.
|
||||||
|
// To compile the program with the correct version information, compile the following way:
|
||||||
|
//
|
||||||
|
// `go build -ldflags="-X 'main.versionString=x.y.z'"`, where `x.y.z` is the correct and valid version from the git tag.
|
||||||
|
// This variable may or may not contain the prefix v.
|
||||||
|
var versionString = "0.0.0-development"
|
||||||
|
|
||||||
|
// version of the program.
|
||||||
|
//
|
||||||
|
// When converted into a string, this will not contain the v prefix.
|
||||||
|
var version = semver.Must(semver.NewVersion(strings.TrimPrefix(versionString, "v")))
|
3
go.mod
3
go.mod
@ -4,10 +4,12 @@ go 1.18
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cheggaaa/pb/v3 v3.1.0
|
github.com/cheggaaa/pb/v3 v3.1.0
|
||||||
|
github.com/coreos/go-semver v0.3.0
|
||||||
github.com/google/hilbert v0.0.0-20181122061418-320f2e35a565
|
github.com/google/hilbert v0.0.0-20181122061418-320f2e35a565
|
||||||
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329
|
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329
|
||||||
github.com/manifoldco/promptui v0.9.0
|
github.com/manifoldco/promptui v0.9.0
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
|
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75
|
||||||
golang.org/x/image v0.0.0-20220617043117-41969df76e82
|
golang.org/x/image v0.0.0-20220617043117-41969df76e82
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,4 +25,5 @@ require (
|
|||||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
7
go.sum
7
go.sum
@ -12,6 +12,8 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk
|
|||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
|
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
|
||||||
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
|
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
|
||||||
|
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
||||||
|
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||||
@ -42,6 +44,8 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S
|
|||||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
|
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75 h1:x03zeu7B2B11ySp+daztnwM5oBJ/8wGUSqrwcw9L0RA=
|
||||||
|
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
|
||||||
golang.org/x/image v0.0.0-20220617043117-41969df76e82 h1:KpZB5pUSBvrHltNEdK/tw0xlPeD13M6M6aGP32gKqiw=
|
golang.org/x/image v0.0.0-20220617043117-41969df76e82 h1:KpZB5pUSBvrHltNEdK/tw0xlPeD13M6M6aGP32gKqiw=
|
||||||
golang.org/x/image v0.0.0-20220617043117-41969df76e82/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
|
golang.org/x/image v0.0.0-20220617043117-41969df76e82/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
|
||||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
@ -56,3 +60,6 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JC
|
|||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
79
scripts/dist/compress.go
vendored
Normal file
79
scripts/dist/compress.go
vendored
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Copyright (c) 2022 David Vogel
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"archive/zip"
|
||||||
|
"io"
|
||||||
|
"io/fs"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
|
)
|
||||||
|
|
||||||
|
// addPathToZip adds the given file or directory at srcPath to the zipWriter.
|
||||||
|
//
|
||||||
|
// The ignorePaths list is compared to the archive path (archive base path + relative path).
|
||||||
|
func addPathToZip(zipWriter *zip.Writer, srcPath, archiveBasePath string, ignorePaths []string) error {
|
||||||
|
return filepath.WalkDir(srcPath, func(path string, d fs.DirEntry, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
relPath, err := filepath.Rel(srcPath, path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
archivePath := filepath.Join(archiveBasePath, relPath)
|
||||||
|
|
||||||
|
// Skip if path is in ignore list.
|
||||||
|
// This applies to directories or files.
|
||||||
|
if slices.Contains(ignorePaths, archivePath) {
|
||||||
|
log.Printf("Skipped %q", archivePath)
|
||||||
|
if d.IsDir() {
|
||||||
|
return fs.SkipDir
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore directories.
|
||||||
|
if d.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
fileToZip, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer fileToZip.Close()
|
||||||
|
|
||||||
|
info, err := fileToZip.Stat()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
header, err := zip.FileInfoHeader(info)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
header.Name = archivePath
|
||||||
|
header.Method = zip.Deflate
|
||||||
|
|
||||||
|
writer, err := zipWriter.CreateHeader(header)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = io.Copy(writer, fileToZip); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
70
scripts/dist/main.go
vendored
Normal file
70
scripts/dist/main.go
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// Copyright (c) 2022 David Vogel
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"archive/zip"
|
||||||
|
"compress/flate"
|
||||||
|
"flag"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
clean := flag.Bool("clean", true, "Remove distribution dir before starting")
|
||||||
|
dist := flag.String("dist", "dist", "Directory to put distribution files in")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
|
if *clean {
|
||||||
|
os.RemoveAll(*dist)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create dist directory tree.
|
||||||
|
os.MkdirAll(filepath.Join(*dist), 0755)
|
||||||
|
|
||||||
|
toCopy := []string{
|
||||||
|
"AREAS.md", "compatibility.xml", "init.lua", "LICENSE", "mod.xml", "README.md",
|
||||||
|
|
||||||
|
filepath.Join("bin", "capture-b", "capture.dll"), filepath.Join("bin", "capture-b", "README.md"),
|
||||||
|
filepath.Join("bin", "stitch", "stitch.exe"), filepath.Join("bin", "stitch", "README.md"),
|
||||||
|
filepath.Join("data"),
|
||||||
|
filepath.Join("files"),
|
||||||
|
filepath.Join("images"),
|
||||||
|
}
|
||||||
|
|
||||||
|
toIgnore := []string{
|
||||||
|
filepath.Join("noita-mapcap", "images", "coordinates.pdn"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create distribution archive.
|
||||||
|
newZipFile, err := os.Create(filepath.Join("dist", "dist.zip"))
|
||||||
|
if err != nil {
|
||||||
|
log.Panicf("Couldn't create output archive: %v", err)
|
||||||
|
}
|
||||||
|
defer newZipFile.Close()
|
||||||
|
|
||||||
|
zipWriter := zip.NewWriter(newZipFile)
|
||||||
|
defer zipWriter.Close()
|
||||||
|
|
||||||
|
zipWriter.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
|
||||||
|
return flate.NewWriter(out, flate.BestCompression)
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, v := range toCopy {
|
||||||
|
srcPath, archivePath := filepath.Join(".", v), filepath.Join("noita-mapcap", v)
|
||||||
|
if err := addPathToZip(zipWriter, srcPath, archivePath, toIgnore); err != nil {
|
||||||
|
log.Panicf("Failed to copy %q into distribution directory: %v", v, err)
|
||||||
|
}
|
||||||
|
log.Printf("Copied %q", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Distribution script complete in %v", time.Since(start))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user