Skip to content

Commit

Permalink
Fixup prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
udnay committed Feb 25, 2025
1 parent 06cdd66 commit 2c3ef92
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Prerelease

on:
push:
branches:
- prerelease
tags:
- "*-pre.*"
defaults:
run:
shell: bash -l {0}
Expand All @@ -25,24 +25,26 @@ jobs:
echo "No tag found, use make prerelease to create a tag"
exit 1
fi
- name: Set env var for tag
run: echo "CUSTOM_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean --snapshot -f .goreleaser.prerelease.yml
args: release --clean --snapshot -f .goreleaser.prerelease.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CUSTOM_VERSION: ${{ env.CUSTOM_VERSION }}
- name: Create prerelease
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "pre-${{ github.sha }}"
tag_name: ${{ env.CUSTOM_VERSION }}
prerelease: true
make_latest: false
name: "Prelease: pre-${{ github.sha }}"
name: "Prelease: ${{ env.CUSTOM_VERSION }}"
files: |
dist/*.tar.gz
dist/checksum*
6 changes: 3 additions & 3 deletions .goreleaser.prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version=v{{.Version}}
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version={{.Env.CUSTOM_VERSION}}
goos:
- linux
- darwin
Expand All @@ -19,7 +19,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version=v{{.Version}}
- -s -w -X github.com/gadget-inc/dateilager/pkg/version.Version={{.Env.CUSTOM_VERSION}}
goos:
- linux
- darwin
Expand All @@ -39,7 +39,7 @@ checksum:
- glob: ./dist/migrations.tar.gz

archives:
- name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
- name_template: "{{ .ProjectName }}-{{ .Env.CUSTOM_VERSION }}-{{ .Os }}-{{ .Arch }}"

release:
extra_files:
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MIGRATE_DIR := ./migrations
SERVICE := $(PROJECT).server
BENCH_PROFILE ?= ""

.PHONY: migrate migrate-create clean build lint release
.PHONY: migrate migrate-create clean build lint release prerelease
.PHONY: test test-one test-fuzz test-js lint-js install-js build-js
.PHONY: reset-db setup-local build-cache-version server server-profile cached
.PHONY: client-update client-large-update client-get client-rebuild client-rebuild-with-cache
Expand Down Expand Up @@ -94,6 +94,20 @@ release: release/client_linux_amd64 release/client_macos_amd64 release/client_ma
release: release/cached_linux_amd64 release/cached_macos_amd64 release/cached_macos_arm64 release/cached_linux_arm64
release: release/migrations.tar.gz

prerelease: build
prerelease:
ifndef tag
$(error tag variable must be set)
else
git tag -f v$(tag) $(shell git rev-parse HEAD)
endif
ifndef force
git push origin $(shell git branch --show-current)
else
git push origin +$(shell git branch --show-current)
endif
git push origin $(tag)

test: export DB_URI = postgres://$(DB_USER):$(DB_PASS)@$(DB_HOST):5432/dl_tests
test: migrate
cd test && go test
Expand Down

0 comments on commit 2c3ef92

Please sign in to comment.