diff --git a/.github/workflows/release-rc.yaml b/.github/workflows/release-rc.yaml new file mode 100644 index 0000000..7471910 --- /dev/null +++ b/.github/workflows/release-rc.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 353a2f1..5e2762e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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: @@ -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 diff --git a/.goreleaser-rc.yaml b/.goreleaser-rc.yaml new file mode 100644 index 0000000..9e89cb4 --- /dev/null +++ b/.goreleaser-rc.yaml @@ -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 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 65efa45..ae7ab9b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -39,7 +39,7 @@ release: draft: false brews: - - name: "{{ .Env.HOMEBREW_APP_NAME }}" + - name: chatgpt-tui tap: owner: tearingItUp786 name: homebrew-tearingitup786 diff --git a/Makefile b/Makefile index 326bb9e..ef594a1 100644 --- a/Makefile +++ b/Makefile @@ -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