Skip to content

Commit

Permalink
Chore: introduce new action and file for release candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
Taranveer Bains committed Mar 8, 2024
1 parent e59d77c commit d69ffd6
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 13 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release-rc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: rc-release
on:
push:
tags:
- v*
jobs:
check-tag:
runs-on: ubuntu-latest
if: "!contains(github.ref, '-rc')"
steps:
- name: Check for RC in tag
run: |
echo "No RC tag was detected: ${GITHUB_REF##*/}"
echo "Cancelling the workflow"
exit 1
release:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
submodules: "true"
- run: git fetch --prune --unshallow
- name: setup dependencies
uses: actions/setup-go@v2
- name: release dry run
run: |
make release-candidate-dry-run
- name: setup release environment
run: |
echo "GITHUB_TOKEN=${{ secrets.PUBLISHER_TOKEN }}" >> .release-env
env:
HOMEBREW_APP_NAME: ${{ env.HOMEBREW_APP_NAME }}
- name: release publish
run: |
make release-candidate
21 changes: 9 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ on:
tags:
- v*
jobs:
check-tag:
runs-on: ubuntu-latest
if: contains(github.ref, '-rc')
steps:
- name: Check for RC in tag
run: |
echo "RC tag detected: ${GITHUB_REF##*/}"
echo "Cancelling the workflow"
exit 1
release:
runs-on: ubuntu-latest
steps:
Expand All @@ -14,18 +23,6 @@ jobs:
- run: git fetch --prune --unshallow
- name: setup dependencies
uses: actions/setup-go@v2
- name: Determine Release Type
id: release_type
run: |
if [[ "${{ github.ref }}" == *"-rc"* ]]; then
echo "Setting up for a release candidate"
echo "HOMEBREW_APP_NAME=rc-chatgpt-tui" >> $GITHUB_ENV
else
echo "Setting up for a stable release"
echo "HOMEBREW_APP_NAME=chatgpt-tui" >> $GITHUB_ENV
fi
env:
GITHUB_REF: ${{ github.ref }}
- name: release dry run
run: |
make release-dry-run
Expand Down
57 changes: 57 additions & 0 deletions .goreleaser-rc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
builds:
- id: darwin-amd64
main: ./
goos:
- darwin
goarch:
- amd64
- arm64

env:
- PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/amd64
- PKG_CONFIG_PATH=/sysroot/macos/amd64/usr/local/lib/pkgconfig
- CC=o64-clang
- CXX=o64-clang++
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Version}}
archives:
- id: chatgpt-tui
builds:
- darwin-amd64
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format: zip
wrap_in_directory: true
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
prerelease: auto
draft: false

brews:
- name: rc-chatgpt-tui
tap:
owner: tearingItUp786
name: homebrew-tearingitup786
homepage: https://github.com/tearingItUp786/chatgpt-tui
commit_author:
name: tearingitup786

# Setting this will prevent goreleaser to actually try to commit the updated
# formula - instead, the formula file will be stored on the dist folder only,
# leaving the responsibility of publishing it to the user.
# If set to auto, the release will not be uploaded to the homebrew tap
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
#
# Templates: allowed
skip_upload: auto
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ release:
draft: false

brews:
- name: "{{ .Env.HOMEBREW_APP_NAME }}"
- name: chatgpt-tui
tap:
owner: tearingItUp786
name: homebrew-tearingitup786
Expand Down
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,37 @@ release:
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean


.PHONY: release-candidate-dry-run
release-candidate-dry-run:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip-validate --skip-publish --config=.goreleaser-rc.yaml

.PHONY: release-candidate
release-candidate:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
@echo "Contents of .release-env:"
@cat .release-env
@echo "Running release..."

docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --config=.goreleaser-rc.yaml

0 comments on commit d69ffd6

Please sign in to comment.