ci: add dev release action

This commit is contained in:
divyam234 2024-02-08 23:01:13 +05:30
parent 3ba530ec7d
commit 66cdb5bac9
5 changed files with 124 additions and 11 deletions

43
.github/workflows/release-dev.yml vendored Normal file
View file

@ -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 }}

View file

@ -3,10 +3,9 @@ name: Goreleaser
on:
push:
tags:
- "*"
- "[0-9].[0-9]+.[0-9]+"
permissions:
contents: write
permissions: write-all
jobs:
goreleaser:
@ -17,11 +16,23 @@ 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
with:

47
.goreleaser.dev.yml Normal file
View file

@ -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

View file

@ -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:

View file

@ -2,16 +2,16 @@ 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
@ -76,3 +76,15 @@ 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))
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)