diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a32f081 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,59 @@ +name: Generate Next Release + +on: + workflow_dispatch: + +permissions: + contents: write # needed to create the GitHub release and upload binary artifacts + pull-requests: write # needed for "included in release" comments from semantic-release bot + +jobs: + release: + name: Release + runs-on: ubuntu-latest + outputs: + new_release_published: ${{ steps.release.outputs.new_release_published }} + new_release_git_tag: ${{ steps.release.outputs.new_release_git_tag }} + steps: + - name: Checkout + uses: actions/checkout@v4.0.0 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5.0.0 + with: + go-version-file: go.mod + - name: Release + id: release + uses: cycjimmy/semantic-release-action@v4.2.2 + with: + semantic_version: 24.0.0 + extra_plugins: | + conventional-changelog-conventionalcommits@8.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish: + name: Publish + needs: release + if: needs.release.outputs.new_release_published == 'true' + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + ref: "${{ needs.release.outputs.new_release_git_tag }}" + + - name: Set up Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: './go.mod' + id: go + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index e660fd9..2e0a5b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ bin/ +dist diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..4d47bf0 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,32 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +version: 2 + +before: + hooks: + - go mod tidy +builds: + - main: ./main.go + env: + - CGO_ENABLED=0 + binary: equinix + ldflags: + - -s -w -X github.com/equinix/cli/internal/version.Version={{.Version}} + + goos: + - freebsd + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + +archives: + - formats: + - 'binary' + name_template: "equinix-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" +checksum: + name_template: "equinix_{{ .Version }}_checksums.txt" +release: + mode: "keep-existing" diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..f70756f --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,28 @@ +{ + "branches": [ + "main" + ], + "ci": false, + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/github", + { + "successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:", + "labels": false, + "releasedLabels": false + } + ] + ] +}