X Tutup
Skip to content

Commit ce3d079

Browse files
authored
Merge branch 'trunk' into multi-devcontainer
2 parents 71d6e61 + bb4fc52 commit ce3d079

File tree

171 files changed

+7546
-1504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+7546
-1504
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extensions": [
3+
"golang.go"
4+
]
5+
}

.github/workflows/codeql.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ on:
1010
schedule:
1111
- cron: "0 0 * * 0"
1212

13+
permissions:
14+
actions: read # for github/codeql-action/init to get workflow details
15+
contents: read # for actions/checkout to fetch code
16+
security-events: write # for github/codeql-action/analyze to upload SARIF results
17+
1318
jobs:
1419
CodeQL-Build:
1520
runs-on: ubuntu-latest
1621

1722
steps:
1823
- name: Check out code
19-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
2025

2126
- name: Initialize CodeQL
2227
uses: github/codeql-action/init@v1

.github/workflows/go.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Tests
22
on: [push, pull_request]
3+
4+
permissions:
5+
contents: read
6+
37
jobs:
48
build:
59
strategy:
@@ -15,16 +19,15 @@ jobs:
1519
go-version: 1.16
1620

1721
- name: Check out code
18-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
1923

20-
- name: Cache Go modules
24+
- name: Restore Go modules cache
2125
uses: actions/cache@v2
2226
with:
23-
path: ~/go
24-
key: ${{ runner.os }}-build-${{ hashFiles('go.mod') }}
27+
path: ~/go/pkg/mod
28+
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
2529
restore-keys: |
26-
${{ runner.os }}-build-
27-
${{ runner.os }}-
30+
go-${{ runner.os }}-
2831
2932
- name: Download dependencies
3033
run: go mod download

.github/workflows/issueauto.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ name: Issue Automation
22
on:
33
issues:
44
types: [opened]
5+
6+
permissions:
7+
contents: none
8+
issues: write
9+
510
jobs:
611
issue-auto:
712
runs-on: ubuntu-latest
813
steps:
914
- name: label incoming issue
1015
env:
11-
GH_REPO: ${{ github.repository }}
12-
GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN }}
13-
ISSUENUM: ${{ github.event.issue.number }}
14-
ISSUEAUTHOR: ${{ github.event.issue.user.login }}
16+
GH_REPO: ${{ github.repository }}
17+
GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN }}
18+
ISSUENUM: ${{ github.event.issue.number }}
19+
ISSUEAUTHOR: ${{ github.event.issue.user.login }}
1520
run: |
1621
if ! gh api orgs/cli/public_members/$ISSUEAUTHOR --silent 2>/dev/null
1722
then

.github/workflows/lint.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- go.mod
1212
- go.sum
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
lint:
1619
runs-on: ubuntu-latest
@@ -22,14 +25,22 @@ jobs:
2225
go-version: 1.16
2326

2427
- name: Check out code
25-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
29+
30+
- name: Restore Go modules cache
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/go/pkg/mod
34+
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
35+
restore-keys: |
36+
go-${{ runner.os }}-
2637
2738
- name: Verify dependencies
2839
run: |
2940
go mod verify
3041
go mod download
3142
32-
LINT_VERSION=1.39.0
43+
LINT_VERSION=1.44.2
3344
curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \
3445
tar xz --strip-components 1 --wildcards \*/golangci-lint
3546
mkdir -p bin && mv golangci-lint bin/

.github/workflows/prauto.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: PR Automation
22
on:
33
pull_request_target:
44
types: [ready_for_review, opened, reopened]
5+
6+
permissions:
7+
contents: none
8+
issues: write
9+
pull-requests: write
10+
511
jobs:
612
pr-auto:
713
runs-on: ubuntu-latest

.github/workflows/releases.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ on:
55
tags:
66
- "v*"
77

8+
permissions:
9+
contents: write # publishing releases
10+
repository-projects: write # move cards between columns
11+
812
jobs:
913
goreleaser:
1014
runs-on: ubuntu-latest
1115
steps:
1216
- name: Checkout
13-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1418
- name: Set up Go 1.16
1519
uses: actions/setup-go@v2
1620
with:
@@ -27,6 +31,13 @@ jobs:
2731
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2832
- name: Install osslsigncode
2933
run: sudo apt-get install -y osslsigncode
34+
- name: Obtain signing cert
35+
run: |
36+
cert="$(mktemp -t cert.XXX)"
37+
base64 -d <<<"$CERT_CONTENTS" > "$cert"
38+
echo "CERT_FILE=$cert" >> $GITHUB_ENV
39+
env:
40+
CERT_CONTENTS: ${{ secrets.WINDOWS_CERT_PFX }}
3041
- name: Run GoReleaser
3142
uses: goreleaser/goreleaser-action@v2
3243
with:
@@ -35,10 +46,9 @@ jobs:
3546
env:
3647
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
3748
GORELEASER_CURRENT_TAG: ${{steps.changelog.outputs.tag-name}}
38-
GITHUB_CERT_PASSWORD: ${{secrets.GITHUB_CERT_PASSWORD}}
39-
DESKTOP_CERT_TOKEN: ${{secrets.DESKTOP_CERT_TOKEN}}
49+
CERT_PASSWORD: ${{secrets.WINDOWS_CERT_PASSWORD}}
4050
- name: Checkout documentation site
41-
uses: actions/checkout@v2
51+
uses: actions/checkout@v3
4252
with:
4353
repository: github/cli.github.com
4454
path: site
@@ -122,7 +132,7 @@ jobs:
122132
runs-on: windows-latest
123133
steps:
124134
- name: Checkout
125-
uses: actions/checkout@v2
135+
uses: actions/checkout@v3
126136
- name: Download gh.exe
127137
id: download_exe
128138
shell: bash
@@ -132,34 +142,33 @@ jobs:
132142
unzip -o *.zip && rm -v *.zip
133143
env:
134144
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
135-
- name: Install go-msi
136-
run: choco install -y "go-msi"
137145
- name: Prepare PATH
138-
shell: bash
139-
run: |
140-
echo "$WIX\\bin" >> $GITHUB_PATH
141-
echo "C:\\Program Files\\go-msi" >> $GITHUB_PATH
146+
id: setupmsbuild
147+
uses: microsoft/setup-msbuild@v1.0.3
142148
- name: Build MSI
143149
id: buildmsi
144150
shell: bash
145151
env:
146152
ZIP_FILE: ${{ steps.download_exe.outputs.zip }}
153+
MSBUILD_PATH: ${{ steps.setupmsbuild.outputs.msbuildPath }}
147154
run: |
148-
mkdir -p build
149-
msi="$(basename "$ZIP_FILE" ".zip").msi"
150-
printf "::set-output name=msi::%s\n" "$msi"
151-
go-msi make --msi "$PWD/$msi" --out "$PWD/build" --version "${GITHUB_REF#refs/tags/}"
155+
name="$(basename "$ZIP_FILE" ".zip")"
156+
version="$(echo -e ${GITHUB_REF#refs/tags/v} | sed s/-.*$//)"
157+
"${MSBUILD_PATH}\MSBuild.exe" ./build/windows/gh.wixproj -p:SourceDir="$PWD" -p:OutputPath="$PWD" -p:OutputName="$name" -p:ProductVersion="$version"
152158
- name: Obtain signing cert
153159
id: obtain_cert
160+
shell: bash
161+
run: |
162+
base64 -d <<<"$CERT_CONTENTS" > ./cert.pfx
163+
printf "::set-output name=cert-file::%s\n" ".\\cert.pfx"
154164
env:
155-
DESKTOP_CERT_TOKEN: ${{ secrets.DESKTOP_CERT_TOKEN }}
156-
run: .\script\setup-windows-certificate.ps1
165+
CERT_CONTENTS: ${{ secrets.WINDOWS_CERT_PFX }}
157166
- name: Sign MSI
158167
env:
159168
CERT_FILE: ${{ steps.obtain_cert.outputs.cert-file }}
160169
EXE_FILE: ${{ steps.buildmsi.outputs.msi }}
161-
GITHUB_CERT_PASSWORD: ${{ secrets.GITHUB_CERT_PASSWORD }}
162-
run: .\script\sign.ps1 -Certificate $env:CERT_FILE -Executable $env:EXE_FILE
170+
CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
171+
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
163172
- name: Upload MSI
164173
shell: bash
165174
run: |
@@ -183,7 +192,7 @@ jobs:
183192
env:
184193
COMMITTER_TOKEN: ${{ secrets.UPLOAD_GITHUB_TOKEN }}
185194
- name: Checkout scoop bucket
186-
uses: actions/checkout@v2
195+
uses: actions/checkout@v3
187196
with:
188197
repository: cli/scoop-gh
189198
path: scoop-gh

.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/client.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,23 @@ func ScopesSuggestion(resp *http.Response) string {
236236
for _, s := range strings.Split(tokenHasScopes, ",") {
237237
s = strings.TrimSpace(s)
238238
gotScopes[s] = struct{}{}
239-
if strings.HasPrefix(s, "admin:") {
239+
240+
// Certain scopes may be grouped under a single "top-level" scope. The following branch
241+
// statements include these grouped/implied scopes when the top-level scope is encountered.
242+
// See https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps.
243+
if s == "repo" {
244+
gotScopes["repo:status"] = struct{}{}
245+
gotScopes["repo_deployment"] = struct{}{}
246+
gotScopes["public_repo"] = struct{}{}
247+
gotScopes["repo:invite"] = struct{}{}
248+
gotScopes["security_events"] = struct{}{}
249+
} else if s == "user" {
250+
gotScopes["read:user"] = struct{}{}
251+
gotScopes["user:email"] = struct{}{}
252+
gotScopes["user:follow"] = struct{}{}
253+
} else if s == "codespace" {
254+
gotScopes["codespace:secrets"] = struct{}{}
255+
} else if strings.HasPrefix(s, "admin:") {
240256
gotScopes["read:"+strings.TrimPrefix(s, "admin:")] = struct{}{}
241257
gotScopes["write:"+strings.TrimPrefix(s, "admin:")] = struct{}{}
242258
} else if strings.HasPrefix(s, "write:") {
@@ -326,6 +342,7 @@ func (c Client) REST(hostname string, method string, p string, body io.Reader, d
326342
if err != nil {
327343
return err
328344
}
345+
329346
err = json.Unmarshal(b, &data)
330347
if err != nil {
331348
return err

api/queries_pr.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,7 @@ type PullRequest struct {
8080
Commit struct {
8181
StatusCheckRollup struct {
8282
Contexts struct {
83-
Nodes []struct {
84-
TypeName string `json:"__typename"`
85-
Name string `json:"name"`
86-
Context string `json:"context,omitempty"`
87-
State string `json:"state,omitempty"`
88-
Status string `json:"status"`
89-
Conclusion string `json:"conclusion"`
90-
StartedAt time.Time `json:"startedAt"`
91-
CompletedAt time.Time `json:"completedAt"`
92-
DetailsURL string `json:"detailsUrl"`
93-
TargetURL string `json:"targetUrl,omitempty"`
94-
}
83+
Nodes []CheckContext
9584
PageInfo struct {
9685
HasNextPage bool
9786
EndCursor string
@@ -113,6 +102,19 @@ type PullRequest struct {
113102
ReviewRequests ReviewRequests
114103
}
115104

105+
type CheckContext struct {
106+
TypeName string `json:"__typename"`
107+
Name string `json:"name"`
108+
Context string `json:"context,omitempty"`
109+
State string `json:"state,omitempty"`
110+
Status string `json:"status"`
111+
Conclusion string `json:"conclusion"`
112+
StartedAt time.Time `json:"startedAt"`
113+
CompletedAt time.Time `json:"completedAt"`
114+
DetailsURL string `json:"detailsUrl"`
115+
TargetURL string `json:"targetUrl,omitempty"`
116+
}
117+
116118
type PRRepository struct {
117119
ID string `json:"id"`
118120
Name string `json:"name"`

0 commit comments

Comments
 (0)
X Tutup