diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8813d6..654c75e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,9 +18,9 @@ jobs: with: go-version: 1.18.1 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: - version: latest + version: v2.10.2 args: release -f .goreleaser/mac.yml --clean env: GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} @@ -49,9 +49,9 @@ jobs: with: go-version: 1.18.1 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: - version: latest + version: v2.10.2 args: release -f .goreleaser/linux.yml --clean env: GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} @@ -70,41 +70,40 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 with: - version: latest + version: v2.10.2 args: release -f .goreleaser/windows.yml --clean env: GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} - build-windows-npm: - runs-on: windows-latest - steps: - - name: Code checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.18.1 - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - with: - version: latest - args: release -f .goreleaser/windows-npm.yml --clean - env: - GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} - publish-npm: runs-on: ubuntu-latest - needs: [build-windows-npm, build-linux, build-mac] + needs: [build-windows, build-linux, build-mac] steps: - uses: actions/checkout@v4 with: - # Checkout on main so that the later commit works - ref: main # With permission to push to a protected branch token: ${{ secrets.READ_WRITE_PAT }} - + fetch-depth: 0 # Required to find branches for a tag + + - name: Determine release branch + id: get_branch + run: | + # Find the branch that contains the tag. + # Prefers 'main', then 'master', then the first branch found. + BRANCHES=$(git branch -r --contains ${{ github.ref_name }} | sed 's/ *origin\///' | grep -v HEAD) + if echo "$BRANCHES" | grep -q -w "main"; then + RELEASE_BRANCH="main" + elif echo "$BRANCHES" | grep -q -w "master"; then + RELEASE_BRANCH="master" + else + RELEASE_BRANCH=$(echo "$BRANCHES" | head -n 1) + fi + echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT + echo "Determined release branch for commit: ${RELEASE_BRANCH}" + + - name: Checkout release branch + run: git checkout ${{ steps.get_branch.outputs.RELEASE_BRANCH }} + - uses: actions/setup-node@v4 with: node-version: "20.x" @@ -133,6 +132,18 @@ jobs: add: 'package.json' - run: npm ci - - run: npm publish + + - name: Determine npm tag for pre-releases + id: npm_tag + run: | + TAG_VERSION="${{ steps.tag-version.outputs.TAG_VERSION }}" + NPM_TAG="latest" + if [[ "$TAG_VERSION" == *-* ]]; then + NPM_TAG=$(echo "$TAG_VERSION" | cut -d'-' -f2 | cut -d'.' -f1) + fi + echo "tag=${NPM_TAG}" >> $GITHUB_OUTPUT + echo "npm tag: ${NPM_TAG}" + + - run: npm publish --tag ${{ steps.npm_tag.outputs.tag }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c14f684..a936e1f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,9 +23,9 @@ jobs: with: go-version: 1.18.1 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: - version: latest + version: v2.10.2 args: release --skip=publish --snapshot -f .goreleaser/mac.yml --clean env: GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} @@ -55,9 +55,9 @@ jobs: with: go-version: 1.18.1 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: - version: latest + version: v2.10.2 args: release --skip=publish --snapshot -f .goreleaser/linux.yml --clean env: GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} @@ -76,26 +76,7 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 with: - version: latest + version: v2.10.2 args: release --skip=publish --snapshot -f .goreleaser/windows.yml --clean env: GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} - - build-windows-npm: - runs-on: windows-latest - steps: - - name: Code checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.18.1 - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - with: - version: latest - args: release --skip=publish --snapshot -f .goreleaser/windows-npm.yml --clean - env: - GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} diff --git a/.goreleaser/linux.yml b/.goreleaser/linux.yml index 4bd9e69..d5999a2 100644 --- a/.goreleaser/linux.yml +++ b/.goreleaser/linux.yml @@ -1,3 +1,4 @@ +version: 2 env: - GO111MODULE=on before: @@ -55,8 +56,8 @@ dockers: ids: - hookdeck-linux image_templates: - - "hookdeck/hookdeck-cli:latest-amd64" - "hookdeck/hookdeck-cli:{{ .Tag }}-amd64" + - "{{ if not .Prerelease }}hookdeck/hookdeck-cli:latest-amd64{{ end }}" build_flag_templates: - "--pull" - "--label=org.opencontainers.image.created={{.Date}}" @@ -71,8 +72,8 @@ dockers: ids: - hookdeck-linux-arm64 image_templates: - - "hookdeck/hookdeck-cli:latest-arm64" - "hookdeck/hookdeck-cli:{{ .Tag }}-arm64" + - "{{ if not .Prerelease }}hookdeck/hookdeck-cli:latest-arm64{{ end }}" build_flag_templates: - "--pull" - "--label=org.opencontainers.image.created={{.Date}}" @@ -83,11 +84,12 @@ dockers: - "--label=homepage=https://hookdeck.com" - "--platform=linux/arm64/v8" docker_manifests: - - name_template: "hookdeck/hookdeck-cli:latest" - image_templates: - - "hookdeck/hookdeck-cli:latest-amd64" - - "hookdeck/hookdeck-cli:latest-arm64" - name_template: "hookdeck/hookdeck-cli:{{ .Tag }}" image_templates: - "hookdeck/hookdeck-cli:{{ .Tag }}-amd64" - "hookdeck/hookdeck-cli:{{ .Tag }}-arm64" + - name_template: "hookdeck/hookdeck-cli:latest" + image_templates: + - "hookdeck/hookdeck-cli:latest-amd64" + - "hookdeck/hookdeck-cli:latest-arm64" + skip_push: auto diff --git a/.goreleaser/mac.yml b/.goreleaser/mac.yml index 0afde56..4752a63 100644 --- a/.goreleaser/mac.yml +++ b/.goreleaser/mac.yml @@ -1,3 +1,4 @@ +version: 2 env: - GO111MODULE=on before: @@ -36,8 +37,9 @@ checksum: name_template: "{{ .ProjectName }}-checksums.txt" snapshot: name_template: "{{ .Tag }}-next" -brews: - - repository: +homebrew_casks: + - name: hookdeck + repository: owner: hookdeck name: homebrew-hookdeck commit_author: @@ -45,19 +47,19 @@ brews: email: support@hookdeck.com homepage: https://hookdeck.com description: Hookdeck CLI utility - install: | - bin.install "hookdeck" - rm Dir["#{bin}/{hookdeck-completion.bash,hookdeck-completion.zsh}"] - system bin/"hookdeck", "completion", "--shell", "bash" - system bin/"hookdeck", "completion", "--shell", "zsh" - bash_completion.install "hookdeck-completion.bash" - zsh_completion.install "hookdeck-completion.zsh" - (zsh_completion/"_hookdeck").write <<~EOS - #compdef hookdeck - _hookdeck () { - local e - e=$(dirname ${funcsourcetrace[1]%:*})/hookdeck-completion.zsh - if [[ -f $e ]]; then source $e; fi - } - EOS caveats: "❤ Thanks for installing the Hookdeck CLI! If this is your first time using the CLI, be sure to run `hookdeck login` first." + custom_block: | + postflight do + system "hookdeck", "completion", "--shell", "bash" + system "hookdeck", "completion", "--shell", "zsh" + bash_completion.install "hookdeck-completion.bash" + zsh_completion.install "hookdeck-completion.zsh" + (zsh_completion/"_hookdeck").write <<~EOS + #compdef hookdeck + _hookdeck () { + local e + e=$(dirname ${funcsourcetrace[1]%:*})/hookdeck-completion.zsh + if [[ -f $e ]]; then source $e; fi + } + EOS + end diff --git a/.goreleaser/windows-npm.yml b/.goreleaser/windows-npm.yml deleted file mode 100644 index c7fc2e1..0000000 --- a/.goreleaser/windows-npm.yml +++ /dev/null @@ -1,45 +0,0 @@ -env: - - GO111MODULE=on -before: - hooks: - - go mod download - - go generate ./... -project_name: hookdeck -builds: - - id: hookdeck-windows - ldflags: - - -s -w -X github.com/hookdeck/hookdeck-cli/pkg/version.Version={{.Version}} - binary: hookdeck - env: - - CGO_ENABLED=1 - - CC=x86_64-w64-mingw32-gcc - - CXX=x86_64-w64-mingw32-g++ - main: ./main.go - goos: - - windows - goarch: - - amd64 - - 386 -archives: - - files: - - none* -changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" -checksum: - name_template: "{{ .ProjectName }}-windows-checksums-npm.txt" -snapshot: - name_template: "{{ .Tag }}-next" -scoops: - - repository: - owner: hookdeck - name: scoop-hookdeck - commit_author: - name: hookdeck-ci - email: support@hookdeck.com - homepage: https://hookdeck.com - description: Hookdeck CLI utility - license: Apache 2.0 diff --git a/.goreleaser/windows.yml b/.goreleaser/windows.yml index b442b2e..cf73675 100644 --- a/.goreleaser/windows.yml +++ b/.goreleaser/windows.yml @@ -1,3 +1,4 @@ +version: 2 env: - GO111MODULE=on before: @@ -40,6 +41,7 @@ scoops: - repository: owner: hookdeck name: scoop-hookdeck + name: "{{ if .Prerelease }}hookdeck-beta{{ else }}hookdeck{{ end }}" commit_author: name: hookdeck-ci email: support@hookdeck.com