diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed29aac..2ddccac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ on: push jobs: - run: + build: name: Build runs-on: "ubuntu-latest" steps: @@ -11,19 +11,14 @@ jobs: with: fetch-depth: 0 -# version number - - uses: actions-ecosystem/action-get-latest-tag@v1 - id: get-latest-tag - if: ${{ !env.ACT }} - -# build - uses: actions/setup-go@v3 with: go-version: '1.19' check-latest: true cache: true - + - name: decrypt + if: ${{ !env.ACT }} run: | sudo apt update -y sudo apt install git-crypt xxd -y @@ -32,14 +27,47 @@ jobs: rm ../bedrock-repo-key.key env: REPO_KEY: ${{ secrets.REPO_KEY }} - if: ${{ !env.ACT }} + + - run: go get - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v3 + - name: build + run: make -j + + - uses: actions/cache@v2 + id: restore-build with: - distribution: goreleaser - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + path: ./dist/* + key: ${{ github.sha }} + release: + if: ${{ !env.ACT }} + needs: build + name: Release + runs-on: "ubuntu-latest" + steps: + - uses: actions/cache@v2 + id: restore-build + with: + path: ./dist/* + key: ${{ github.sha }} + + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: get-latest-tag + + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: ${{ steps.get-latest-tag.outputs.tag }} + prerelease: true + title: "Latest Release" + files: | + dist/* + + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: latest + prerelease: true + title: "Latest Development" + files: | + dist/* diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index 3da1737..0000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,46 +0,0 @@ -project_name: bedrocktool - -before: - hooks: - - go mod tidy - - | - bash -c "if [ \"$(head -c 7 resourcepack-ace.go)\" != \"package\" ]; then mv nop.notgo resourcepack-ace.go; fi" - -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin - goarch: - - arm - - arm64 - - amd64 - - 386 - ldflags: - - -s -w -X main.version={{.Version}} - -archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 - -checksum: - name_template: 'checksums.txt' - -snapshot: - name_template: "{{ incpatch .Version }}-next" - -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' - -release: - github: \ No newline at end of file diff --git a/Makefile b/Makefile index 1eae432..0b72003 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,19 @@ -GC = go build -ldflags "-s -w" TAG = $(shell git describe --tags) - NAME = bedrocktool-${TAG} SRCS = $(wildcard *.go) +GC = go build -ldflags "-s -w -X main.version=${TAG}" - +# check if packs are supported HAVE_PACKS = false ifeq ($(shell head -c 7 resourcepack-ace.go),package) HAVE_PACKS = true endif - $(info pack support: ${HAVE_PACKS}) - ifneq ($(HAVE_PACKS),true) GC += -overlay overlay.json endif - BUILDS=\ windows_386.exe\ windows_amd64.exe\ @@ -28,28 +24,24 @@ BUILDS=\ linux_386\ linux_amd64\ linux_arm64\ - linux_arm\ - linux_mips\ - linux_mips64\ - linux_mips64le\ - linux_ppc64\ - linux_ppc64le\ - linux_riscv64\ - linux_s390x + linux_arm -DISTS=$(BUILDS:%=$(NAME)_%) +DISTS=$(BUILDS:%=dist/$(NAME)_%) all: $(DISTS) -.PHONY: all clean $(DISTS) +.PHONY: all clean $(DISTS): OS = $(word 2,$(subst _, ,$@)) $(DISTS): ARCH = $(word 1,$(subst ., ,$(word 3,$(subst _, ,$@)))) -$(DISTS): $(SRCS) +dist: + mkdir -p dist + +$(DISTS): dist $(SRCS) @echo "building: $@" GOOS=$(OS) GOARCH=$(ARCH) $(GC) -o $@ clean: - rm $(NAME).exe $(NAME)-linux $(NAME)-mac \ No newline at end of file + rm -r dist \ No newline at end of file diff --git a/go.mod b/go.mod index 5ff8a6f..5fef173 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/go-gl/mathgl v1.0.0 github.com/google/gopacket v1.1.19 github.com/google/subcommands v1.2.0 - github.com/google/uuid v1.3.0 github.com/miekg/dns v1.1.50 github.com/sandertv/gophertunnel v1.24.0 golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e @@ -28,6 +27,7 @@ require ( github.com/df-mc/atomic v1.10.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/jinzhu/copier v0.3.5 github.com/klauspost/compress v1.15.9 // indirect github.com/muhammadmuzzammil1998/jsonc v1.0.0 // indirect