Skip to content

Commit 176063f

Browse files
authored
Merge pull request #715 from onflow/improvement/release-gha
Release process improvements
2 parents 6483711 + 35ae0f7 commit 176063f

7 files changed

Lines changed: 49 additions & 70 deletions

File tree

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,41 @@
11
name: Build Release
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
release:
5+
types: [created]
76

87
jobs:
9-
security:
8+
releases-matrix:
9+
name: Release Go Binary
1010
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
14+
goos: [ linux, windows, darwin ]
15+
goarch: [ amd64, arm64 ]
16+
exclude:
17+
- goarch: arm64
18+
goos: windows
1119
steps:
12-
- uses: actions/checkout@master
13-
- name: Run Snyk to check for vulnerabilities
20+
- uses: actions/checkout@v3
21+
- name: Codebase security check
1422
continue-on-error: true
1523
uses: snyk/actions/golang@master
1624
with:
1725
go-version: '1.19'
1826
env:
1927
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
20-
build:
21-
runs-on: ubuntu-latest
22-
steps:
23-
- uses: actions/checkout@v2
24-
with:
25-
fetch-depth: 0
26-
- uses: actions/setup-go@v1
27-
with:
28-
go-version: '1.19'
29-
- name: Build Binaries
30-
run: make versioned-binaries
28+
- uses: wangyoucao577/go-release-action@v1.33
3129
env:
3230
MIXPANEL_PROJECT_TOKEN: ${{ secrets.MIXPANEL_PROJECT_TOKEN }}
33-
- name: Uploading Binaries
34-
uses: google-github-actions/upload-cloud-storage@main
35-
with:
36-
credentials: ${{ secrets.FLOW_HOSTING_PROD_SA }}
37-
path: ./cmd/flow/
38-
glob: 'flow-*'
39-
destination: flow-cli/
40-
parent: false
41-
- name: Update Version
42-
uses: google-github-actions/upload-cloud-storage@main
31+
APP_VERSION: $(basename ${GITHUB_REF})
32+
BUILD_TIME: $(date --iso-8601=seconds)
33+
VERSION: ${{github.ref_name}}
34+
COMMIT: ${{ github.sha }}
4335
with:
44-
credentials: ${{ secrets.FLOW_HOSTING_PROD_SA }}
45-
path: ./
46-
glob: 'version.txt'
47-
destination: flow-cli/
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
goos: ${{ matrix.goos }}
38+
goarch: ${{ matrix.goarch }}
39+
goversion: "1.19"
40+
project_path: "./cmd/flow"
41+
ldflags: -X "build.commit=${{ env.COMMIT }}" -X "build.semver=${{ env.VERSION }}" -X "util.MIXPANEL_PROJECT_TOKEN=${{ env.MIXPANEL_PROJECT_TOKEN }}"

.github/workflows/publish-release.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@ on:
55
types: [published]
66

77
jobs:
8-
security:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@master
12-
- name: Run Snyk to check for vulnerabilities
13-
continue-on-error: true
14-
uses: snyk/actions/golang@master
15-
with:
16-
go-version: '1.19'
17-
env:
18-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
198
homebrew:
9+
if: github.event_name == 'release' && github.event.action == 'published' # skip for pre-release
2010
name: Bump Homebrew formula
2111
runs-on: ubuntu-latest
2212
steps:
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: Security Scanner
22
on:
3-
pull_request:
43
push:
5-
workflow_dispatch:
6-
schedule:
7-
- cron: "0 4 * * *" # run once a day at 4 AM
84
jobs:
95
scan:
106
name: gitleaks
@@ -22,9 +18,9 @@ jobs:
2218
steps:
2319
- uses: actions/checkout@v3
2420
- name: Running govulncheck
25-
uses: Templum/govulncheck-action@latest
21+
uses: Templum/govulncheck-action@v0.0.7
2622
with:
27-
go-version: 1.18
23+
go-version: 1.19
2824
vulncheck-version: latest
2925
package: ./...
3026
github-token: ${{ secrets.GITHUB_TOKEN }}

install.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ Set-ItemProperty HKCU:\Console VirtualTerminalLevel -Type DWORD 1
3232

3333
$ErrorActionPreference = "Stop"
3434

35-
$baseURL = "https://storage.googleapis.com/flow-cli"
36-
$versionURL ="https://raw.githubusercontent.com/onflow/flow-cli/master/version.txt"
35+
$repo = "onflow/flow-cli"
36+
$versionURL = "https://api.github.com/repos/$repo/releases/latest"
37+
$assetsURL = "https://github.com/$repo/releases/download"
3738

3839
if (!$version) {
39-
$version = (Invoke-WebRequest -Uri "$versionURL" -UseBasicParsing).Content.Trim()
40+
$q = (Invoke-WebRequest -Uri "$versionURL" -UseBasicParsing) | ConvertFrom-Json
41+
$version = $q.tag_name
4042
}
4143

4244
Write-Output("Installing version {0} ..." -f $version)
@@ -45,7 +47,11 @@ New-Item -ItemType Directory -Force -Path $directory | Out-Null
4547

4648
$progressPreference = 'silentlyContinue'
4749

48-
Invoke-WebRequest -Uri "$baseURL/flow-x86_64-windows-$version" -UseBasicParsing -OutFile "$directory\flow.exe"
50+
Invoke-WebRequest -Uri "$assetsURL/$version/flow-cli-$version-windows-amd64.zip" -UseBasicParsing -OutFile "$directory\flow.zip"
51+
52+
Expand-Archive -Path "$directory\flow.zip" -DestinationPath "$directory"
53+
54+
Move-Item -Path "$directory\flow-cli.exe" -Destination "$directory\flow.exe" -Force
4955

5056
if ($addToPath) {
5157
Write-Output "Adding to PATH ..."

install.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Exit as soon as any command fails
44
set -e
55

6-
BASE_URL="https://storage.googleapis.com/flow-cli"
7-
CLI_GIT_URL="https://raw.githubusercontent.com/onflow/flow-cli/master/version.txt"
6+
REPO="onflow/flow-cli"
7+
ASSETS_URL="https://github.com/$REPO/releases/download/"
88
# The version to download, set by get_version (defaults to args[1])
99
VERSION="$1"
1010
# The architecture string, set by get_architecture
@@ -47,7 +47,7 @@ get_architecture() {
4747
return 1
4848
;;
4949
esac
50-
_arch="${_cputype}-${_ostype}"
50+
_arch="${_ostype}-${_cputype}"
5151
ARCH="${_arch}"
5252
TARGET_PATH="${_targetpath}"
5353
}
@@ -56,7 +56,7 @@ get_architecture() {
5656
get_version() {
5757
if [ -z "$VERSION" ]
5858
then
59-
VERSION=$(curl -s "$CLI_GIT_URL")
59+
VERSION=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep -E 'tag_name' | cut -d '"' -f 4)
6060
fi
6161
}
6262

@@ -71,21 +71,21 @@ main() {
7171
echo "Downloading version $VERSION ..."
7272

7373
tmpfile=$(mktemp 2>/dev/null || mktemp -t flow)
74-
75-
url="$BASE_URL/flow-$ARCH-$VERSION"
76-
curl --progress-bar "$url" -o $tmpfile
74+
url="$ASSETS_URL$VERSION/flow-cli-$VERSION-$ARCH.tar.gz"
75+
curl -L --progress-bar "$url" -o $tmpfile
7776

7877
# Ensure we don't receive a not found error as response.
79-
if grep -q "The specified key does not exist" $tmpfile
78+
if grep -q "Not Found" $tmpfile
8079
then
8180
echo "Version $VERSION could not be found"
8281
exit 1
8382
fi
8483

85-
chmod +x $tmpfile
86-
8784
[ -d $TARGET_PATH ] || mkdir -p $TARGET_PATH
88-
mv $tmpfile $TARGET_PATH/flow
85+
86+
tar -xf $tmpfile -C $TARGET_PATH
87+
mv $TARGET_PATH/flow-cli $TARGET_PATH/flow
88+
chmod +x $TARGET_PATH/flow
8989

9090
echo "Successfully installed the Flow CLI to $TARGET_PATH."
9191
echo "Make sure $TARGET_PATH is in your \$PATH environment variable."

run.ps1

Lines changed: 0 additions & 2 deletions
This file was deleted.

run.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)