diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml new file mode 100644 index 0000000..146d89a --- /dev/null +++ b/.github/workflows/release-dev.yml @@ -0,0 +1,43 @@ +name: Goreleaser + +on: + push: + tags: + - "[0-9].[0-9]+.[0-9]+-dev" + +permissions: write-all + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: true + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: stable + + - uses: pnpm/action-setup@v3 + with: + version: 8 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean --config .goreleaser.dev.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/release.yml similarity index 56% rename from .github/workflows/goreleaser.yml rename to .github/workflows/release.yml index 3ec6486..f571666 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,9 @@ name: Goreleaser on: push: tags: - - "*" + - "[0-9].[0-9]+.[0-9]+" -permissions: - contents: write +permissions: write-all jobs: goreleaser: @@ -17,10 +16,22 @@ jobs: with: fetch-depth: 0 submodules: true + - name: Set up Go uses: actions/setup-go@v4 with: go-version: stable + + - uses: pnpm/action-setup@v3 + with: + version: 8 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 @@ -29,4 +40,4 @@ jobs: version: latest args: release --clean env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.dev.yml b/.goreleaser.dev.yml new file mode 100644 index 0000000..08cd4d5 --- /dev/null +++ b/.goreleaser.dev.yml @@ -0,0 +1,47 @@ +project_name: teldrive +env: + - GO111MODULE=on + +before: + hooks: + - make frontend + +builds: + - env: + - CGO_ENABLED=0 + + main: cmd/teldrive/main.go + flags: -trimpath + ldflags: "-extldflags -static -s -w" + mod_timestamp: "{{ .CommitTimestamp }}" + goos: + - linux + - windows + goarch: + - amd64 +dockers: + - image_templates: + - "ghcr.io/{{ .Env.GITHUB_ACTOR }}/{{ .ProjectName }}:{{ .Tag }}" + use: buildx + dockerfile: Dockerfile + +checksum: + name_template: "{{ .ProjectName }}_checksums.txt" + +archives: + - name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - 'README' + - Merge pull request + - Merge branch +release: + draft: true \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yml similarity index 83% rename from .goreleaser.yaml rename to .goreleaser.yml index 0d683ee..653e361 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yml @@ -24,8 +24,8 @@ builds: - arm64 dockers: - image_templates: - - "gcr.io/{{ .Env.GITHUB_ACTOR }}/{{ .ProjectName }}/server:{{ .Tag }}" - - "gcr.io/{{ .Env.GITHUB_ACTOR }}/{{ .ProjectName }}/server:latest" + - "ghcr.io/{{ .Env.GITHUB_ACTOR }}/{{ .ProjectName }}/server:{{ .Tag }}" + - "ghcr.io/{{ .Env.GITHUB_ACTOR }}/{{ .ProjectName }}/server:latest" use: buildx dockerfile: Dockerfile goos: diff --git a/Makefile b/Makefile index fce98dc..1718c95 100644 --- a/Makefile +++ b/Makefile @@ -2,17 +2,17 @@ FRONTEND_DIR := ui/teldrive-ui BUILD_DIR := bin APP_NAME := teldrive -GIT_VERSION := $(shell git describe --tags --abbrev=0) +GIT_VERSION := $(shell git describe --tags --abbrev=0 --exclude='*dev*') GIT_COMMIT := $(shell git rev-parse --short HEAD) GIT_LINK := $(shell git remote get-url origin) - +GIT_DEV_TAG := $(shell git describe --tags --abbrev=0 --match='*-dev') ENV_FILE := $(FRONTEND_DIR)/.env GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) -.PHONY: all build run clean frontend backend run sync-ui tag-and-push retag - +.PHONY: all build run clean frontend backend run sync-ui tag-and-push retag dev-tag dev-retag + all: build ifdef ComSpec @@ -75,4 +75,16 @@ patch-version: minor-version: @echo "Minoring version..." git tag -a $(shell semver -i minor $(GIT_VERSION)) -m "Release $(shell semver -i minor $(GIT_VERSION))" - git push origin $(shell semver -i minor $(GIT_VERSION)) \ No newline at end of file + git push origin $(shell semver -i minor $(GIT_VERSION)) + +dev-patch: + @echo "Patching version..." + git tag $(shell semver -i patch $(GIT_DEV_TAG)) + git push origin $(shell semver -i patch $(GIT_DEV_TAG)) + +dev-retag: + @echo "Retagging..." + git tag -d $(GIT_DEV_TAG) + git push --delete origin $(GIT_DEV_TAG) + git tag $(GIT_DEV_TAG) + git push origin $(GIT_DEV_TAG) \ No newline at end of file