Skip to content

Commit 84aad52

Browse files
author
Mark Phelps
authored
Merge branch 'cli:trunk' into codespaces-accept-perms
2 parents 590acaa + c2a9c5a commit 84aad52

File tree

14 files changed

+393
-158
lines changed

14 files changed

+393
-158
lines changed

.github/workflows/releases.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ jobs:
2727
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2828
- name: Install osslsigncode
2929
run: sudo apt-get install -y osslsigncode
30+
- name: Obtain signing cert
31+
run: |
32+
cert="$(mktemp -t cert.XXX)"
33+
base64 -d <<<"$CERT_CONTENTS" > "$cert"
34+
echo "CERT_FILE=$cert" >> $GITHUB_ENV
35+
env:
36+
CERT_CONTENTS: ${{ secrets.WINDOWS_CERT_PFX }}
3037
- name: Run GoReleaser
3138
uses: goreleaser/goreleaser-action@v2
3239
with:
@@ -35,8 +42,7 @@ jobs:
3542
env:
3643
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
3744
GORELEASER_CURRENT_TAG: ${{steps.changelog.outputs.tag-name}}
38-
GITHUB_CERT_PASSWORD: ${{secrets.GITHUB_CERT_PASSWORD}}
39-
DESKTOP_CERT_TOKEN: ${{secrets.DESKTOP_CERT_TOKEN}}
45+
CERT_PASSWORD: ${{secrets.WINDOWS_CERT_PASSWORD}}
4046
- name: Checkout documentation site
4147
uses: actions/checkout@v2
4248
with:
@@ -147,15 +153,18 @@ jobs:
147153
"${MSBUILD_PATH}\MSBuild.exe" ./build/windows/gh.wixproj -p:SourceDir="$PWD" -p:OutputPath="$PWD" -p:OutputName="$name" -p:ProductVersion="$version"
148154
- name: Obtain signing cert
149155
id: obtain_cert
156+
shell: bash
157+
run: |
158+
base64 -d <<<"$CERT_CONTENTS" > ./cert.pfx
159+
printf "::set-output name=cert-file::%s\n" ".\\cert.pfx"
150160
env:
151-
DESKTOP_CERT_TOKEN: ${{ secrets.DESKTOP_CERT_TOKEN }}
152-
run: .\script\setup-windows-certificate.ps1
161+
CERT_CONTENTS: ${{ secrets.WINDOWS_CERT_PFX }}
153162
- name: Sign MSI
154163
env:
155164
CERT_FILE: ${{ steps.obtain_cert.outputs.cert-file }}
156165
EXE_FILE: ${{ steps.buildmsi.outputs.msi }}
157-
GITHUB_CERT_PASSWORD: ${{ secrets.GITHUB_CERT_PASSWORD }}
158-
run: .\script\sign.ps1 -Certificate $env:CERT_FILE -Executable $env:EXE_FILE
166+
CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
167+
run: .\script\signtool sign /d "GitHub CLI" /f $env:CERT_FILE /p $env:CERT_PASSWORD /fd sha256 /tr http://timestamp.digicert.com /v $env:EXE_FILE
159168
- name: Upload MSI
160169
shell: bash
161170
run: |

.goreleaser.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ before:
99
hooks:
1010
- go mod tidy
1111
- make manpages GH_VERSION={{.Version}}
12-
- ./script/prepare-windows-cert.sh '{{ if index .Env "GITHUB_CERT_PASSWORD" }}{{ .Env.GITHUB_CERT_PASSWORD}}{{ end }}' '{{ if index .Env "DESKTOP_CERT_TOKEN" }}{{ .Env.DESKTOP_CERT_TOKEN}}{{ end }}'
1312

1413
builds:
1514
- <<: &build_defaults

api/queries_repo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"github.com/cli/cli/v2/internal/ghinstance"
98
"io"
109
"net/http"
1110
"sort"
1211
"strings"
1312
"time"
1413

14+
"github.com/cli/cli/v2/internal/ghinstance"
15+
1516
"github.com/cli/cli/v2/internal/ghrepo"
1617
"github.com/shurcooL/githubv4"
1718
)

docs/install_linux.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ our release schedule.
1414
Install:
1515

1616
```bash
17-
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/etc/apt/trusted.gpg.d/githubcli-archive-keyring.gpg
18-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
17+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
18+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
1919
sudo apt update
2020
sudo apt install gh
2121
```

pkg/cmd/pr/list/list.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type ListOptions struct {
3636
HeadBranch string
3737
Labels []string
3838
Author string
39+
AppAuthor string
3940
Assignee string
4041
Search string
4142
Draft string
@@ -82,6 +83,14 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
8283
opts.Draft = strconv.FormatBool(draft)
8384
}
8485

86+
if err := cmdutil.MutuallyExclusive(
87+
"specify only `--author` or `--app`",
88+
opts.Author != "",
89+
opts.AppAuthor != "",
90+
); err != nil {
91+
return err
92+
}
93+
8594
if runF != nil {
8695
return runF(opts)
8796
}
@@ -99,6 +108,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
99108
cmd.Flags().StringVarP(&opts.HeadBranch, "head", "H", "", "Filter by head branch")
100109
cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by labels")
101110
cmd.Flags().StringVarP(&opts.Author, "author", "A", "", "Filter by author")
111+
cmd.Flags().StringVar(&opts.AppAuthor, "app", "", "Filter by GitHub App author")
102112
cmd.Flags().StringVarP(&opts.Assignee, "assignee", "a", "", "Filter by assignee")
103113
cmd.Flags().StringVarP(&opts.Search, "search", "S", "", "Search pull requests with `query`")
104114
cmd.Flags().BoolVarP(&draft, "draft", "d", false, "Filter by draft state")
@@ -163,6 +173,10 @@ func listRun(opts *ListOptions) error {
163173
return opts.Browser.Browse(openURL)
164174
}
165175

176+
if opts.AppAuthor != "" {
177+
filters.Author = fmt.Sprintf("app/%s", opts.AppAuthor)
178+
}
179+
166180
listResult, err := listPullRequests(httpClient, baseRepo, filters, opts.LimitResults)
167181
if err != nil {
168182
return err

pkg/cmd/pr/list/list_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,53 @@ func TestPRList_filteringDraft(t *testing.T) {
229229
}
230230
}
231231

232+
func TestPRList_filteringAuthor(t *testing.T) {
233+
tests := []struct {
234+
name string
235+
cli string
236+
expectedQuery string
237+
}{
238+
{
239+
name: "author @me",
240+
cli: `--author "@me"`,
241+
expectedQuery: `repo:OWNER/REPO is:pr is:open author:@me`,
242+
},
243+
{
244+
name: "author user",
245+
cli: `--author "monalisa"`,
246+
expectedQuery: `repo:OWNER/REPO is:pr is:open author:monalisa`,
247+
},
248+
{
249+
name: "app author",
250+
cli: `--author "app/dependabot"`,
251+
expectedQuery: `repo:OWNER/REPO is:pr is:open author:app/dependabot`,
252+
},
253+
{
254+
name: "app author with app option",
255+
cli: `--app "dependabot"`,
256+
expectedQuery: `repo:OWNER/REPO is:pr is:open author:app/dependabot`,
257+
},
258+
}
259+
260+
for _, test := range tests {
261+
t.Run(test.name, func(t *testing.T) {
262+
http := initFakeHTTP()
263+
defer http.Verify(t)
264+
265+
http.Register(
266+
httpmock.GraphQL(`query PullRequestSearch\b`),
267+
httpmock.GraphQLQuery(`{}`, func(_ string, params map[string]interface{}) {
268+
assert.Equal(t, test.expectedQuery, params["q"].(string))
269+
}))
270+
271+
_, err := runCommand(http, true, test.cli)
272+
if err != nil {
273+
t.Fatal(err)
274+
}
275+
})
276+
}
277+
}
278+
232279
func TestPRList_withInvalidLimitFlag(t *testing.T) {
233280
http := initFakeHTTP()
234281
defer http.Verify(t)

pkg/cmd/release/create/create.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func createRun(opts *CreateOptions) error {
174174
return err
175175
}
176176

177+
var existingTag bool
177178
if opts.TagName == "" {
178179
tags, err := getTags(httpClient, baseRepo, 5)
179180
if err != nil {
@@ -198,6 +199,7 @@ func createRun(opts *CreateOptions) error {
198199
return fmt.Errorf("could not prompt: %w", err)
199200
}
200201
if tag != createNewTagOption {
202+
existingTag = true
201203
opts.TagName = tag
202204
}
203205
}
@@ -213,14 +215,36 @@ func createRun(opts *CreateOptions) error {
213215
}
214216
}
215217

218+
var tagDescription string
219+
if opts.RepoOverride == "" {
220+
tagDescription, _ = gitTagInfo(opts.TagName)
221+
// If there is a local tag with the same name as specified
222+
// the user may not want to create a new tag on the remote
223+
// as the local one might be annotated or signed.
224+
// If the user specifies the target take that as explict instruction
225+
// to create the tag on the remote pointing to the target regardless
226+
// of local tag status.
227+
// If a remote tag with the same name as specified exists already
228+
// then a new tag will not be created so ignore local tag status.
229+
if tagDescription != "" && !existingTag && opts.Target == "" {
230+
remoteExists, err := remoteTagExists(httpClient, baseRepo, opts.TagName)
231+
if err != nil {
232+
return err
233+
}
234+
if !remoteExists {
235+
return fmt.Errorf("tag %s exists locally but has not been pushed to %s, please push it before continuing or specify the `--target` flag to create a new tag",
236+
opts.TagName, ghrepo.FullName(baseRepo))
237+
}
238+
}
239+
}
240+
216241
if !opts.BodyProvided && opts.IO.CanPrompt() {
217242
editorCommand, err := cmdutil.DetermineEditor(opts.Config)
218243
if err != nil {
219244
return err
220245
}
221246

222247
var generatedNotes *releaseNotes
223-
var tagDescription string
224248
var generatedChangelog string
225249

226250
params := map[string]interface{}{
@@ -236,7 +260,6 @@ func createRun(opts *CreateOptions) error {
236260

237261
if opts.RepoOverride == "" {
238262
headRef := opts.TagName
239-
tagDescription, _ = gitTagInfo(opts.TagName)
240263
if tagDescription == "" {
241264
if opts.Target != "" {
242265
// TODO: use the remote-tracking version of the branch ref
@@ -366,13 +389,6 @@ func createRun(opts *CreateOptions) error {
366389
}
367390
}
368391

369-
if opts.Draft && len(opts.DiscussionCategory) > 0 {
370-
return fmt.Errorf(
371-
"%s Discussions not supported with draft releases",
372-
opts.IO.ColorScheme().FailureIcon(),
373-
)
374-
}
375-
376392
params := map[string]interface{}{
377393
"tag_name": opts.TagName,
378394
"draft": opts.Draft,
@@ -420,7 +436,7 @@ func createRun(opts *CreateOptions) error {
420436
}
421437

422438
if !opts.Draft {
423-
rel, err := publishRelease(httpClient, newRelease.APIURL)
439+
rel, err := publishRelease(httpClient, newRelease.APIURL, opts.DiscussionCategory)
424440
if err != nil {
425441
return err
426442
}

0 commit comments

Comments
 (0)