Skip to content

Commit 0a29da6

Browse files
authored
Merge pull request #2079 from ActiveState/DX-1168
2 parents 45eae70 + 2b53a31 commit 0a29da6

File tree

8 files changed

+168
-8
lines changed

8 files changed

+168
-8
lines changed

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release
2+
3+
# === Triggers ===
4+
"on":
5+
create
6+
7+
# === JOBS ===
8+
jobs:
9+
10+
# === OS Specific Job (runs on each OS) ===
11+
remote-installer:
12+
name: Remote Installer
13+
if: github.event_name == 'create' && github.event.create.ref_type == 'tag' && startsWith('release/remote-installer', github.event.create.ref)
14+
timeout-minutes: 30
15+
runs-on: ubuntu-20.04
16+
env:
17+
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
18+
GOFLAGS: -mod=vendor
19+
SHELL: bash
20+
GITHUB_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
22+
# === OS Specific Steps ===
23+
steps:
24+
25+
- # Checkout Code
26+
name: Checkout code
27+
uses: actions/checkout@v2
28+
29+
- # === Install Go ===
30+
name: Install Go
31+
uses: actions/setup-go@v2
32+
with:
33+
go-version: 1.18.x
34+
35+
- # === Setup ===
36+
name: Setup
37+
shell: bash
38+
run: |
39+
bin=$(pwd)/.github/deps/${{ runner.os }}/bin
40+
echo "Adding $bin to PATH"
41+
echo "$bin" >> $GITHUB_PATH
42+
43+
- # === Setup Windows ===
44+
name: Setup (Windows)
45+
shell: pwsh
46+
run: |
47+
echo "${PSScriptRoot}/.github/deps/${{ runner.os }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
48+
49+
- # === Preprocess ===
50+
name: Preprocess
51+
shell: bash
52+
timeout-minutes: 1
53+
run: state run preprocess
54+
55+
- # === Build Remote Installer ===
56+
name: Build Remote Installer
57+
shell: bash
58+
timeout-minutes: 15
59+
run: |
60+
echo $MSI_CERT_BASE64 | base64 --decode > Cert.p12
61+
export PATH=/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/:/c/Program\ Files\ \(x86\)/Windows\ Kits/10/bin/10.0.16299.0/x86/:$PATH
62+
63+
GOOS=windows state run build-remote-installer
64+
signtool.exe sign -d "ActiveState State Tool Remote Installer" -f "Cert.p12" -p ${CODE_SIGNING_PASSWD} ./build/state-remote-installer.exe
65+
state run generate-remote-install-deployment windows amd64
66+
67+
GOOS=linux state run build-remote-installer
68+
state run generate-remote-install-deployment linux amd64
69+
70+
GOOS=darwin state run build-remote-installer
71+
state run generate-remote-install-deployment darwin amd64
72+
env:
73+
CODE_SIGNING_PASSWD: ${{ secrets.CODE_SIGNING_PASSWD }}
74+
MSI_CERT_BASE64: ${{ secrets.MSI_CERT_BASE64 }}
75+
76+
- # === Deploy ===
77+
name: Deploy
78+
shell: bash
79+
run: state run deploy-remote-installer
80+
env:
81+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
82+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

activestate.generators.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ scripts:
8787
8888
echo "# Remove temp dir"
8989
rm -rf $TEMPDIR
90+
- name: generate-remote-install-deployment
91+
language: bash
92+
value: go run scripts/ci/deploy-generator/remote-installer/main.go "$@"
9093
- name: generate-graph
9194
language: bash
9295
description: Generates graph server and client files

activestate.windows.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ constants:
77
value: state-exec.exe
88
- name: BUILD_INSTALLER_TARGET
99
value: state-installer.exe
10-
- name: BUILD_REMOTE_INSTALLER_TARGET
11-
value: state-remote-installer.exe
1210
- name: BUILD_SYSTRAY_TARGET
1311
value: state-tray.exe
1412
- name: BUILD_UPDLG_TARGET

activestate.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ constants:
4545
if: ne .OS.Name "Windows"
4646
value: state-installer
4747
- name: BUILD_REMOTE_INSTALLER_TARGET
48-
if: ne .OS.Name "Windows"
4948
value: state-remote-installer
5049
- name: SET_ENV
5150
description: The environment settings used throughout our project
@@ -214,7 +213,11 @@ scripts:
214213
value: |
215214
set -e
216215
$constants.SET_ENV
217-
go build -tags "$GO_BUILD_TAGS" -o $BUILD_TARGET_DIR/$constants.BUILD_REMOTE_INSTALLER_TARGET ./cmd/state-remote-installer
216+
TARGET=$BUILD_REMOTE_INSTALLER_TARGET
217+
if [ "$GOOS" == "windows" ]; then
218+
TARGET="${BUILD_REMOTE_INSTALLER_TARGET}.exe"
219+
fi
220+
go build -tags "$GO_BUILD_TAGS" -o $BUILD_TARGET_DIR/$TARGET ./cmd/state-remote-installer
218221
- name: build-updlg-all
219222
description: Invokes all build steps for the update dialog
220223
standalone: true
@@ -328,6 +331,12 @@ scripts:
328331
description: Deploys update files to S3. This steps is automated by CI and should never be ran manually unless you KNOW WHAT YOU'RE DOING.
329332
value: |
330333
go run scripts/ci/s3-deployer/main.go build/installers us-east-1 state-tool update/state
334+
- name: deploy-remote-installer
335+
language: bash
336+
value: |
337+
set -e
338+
$constants.SET_ENV
339+
go run scripts/ci/s3-deployer/main.go $BUILD_TARGET_DIR/remote-installer us-east-1 state-tool remote-installer
331340
- name: deploy-msi
332341
language: bash
333342
value: |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

internal/constants/preprocess/preprocess.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,25 @@ func init() {
2626
commitRef = sha
2727
}
2828

29-
newVersion, err := version.Detect()
29+
newVersion, err := version.Detect("")
3030
if err != nil {
3131
log.Fatalf("Could not parse new version: %s", err)
3232
}
3333

34+
remoteInstallerVersion, err := version.Detect("cmd/state-remote-installer")
35+
if err != nil {
36+
log.Fatalf("Could not parse new remote installer version: %s", err)
37+
}
38+
3439
Constants["BranchName"] = func() interface{} { return branchName }
3540
Constants["BuildNumber"] = func() interface{} { return buildNumber }
3641
Constants["RevisionHash"] = func() interface{} { return getCmdOutput("git rev-parse --verify " + commitRef) }
3742
Constants["RevisionHashShort"] = func() interface{} { return getCmdOutput("git rev-parse --short " + commitRef) }
38-
Constants["Version"] = func() interface{} { return mustVersionWithRevision(newVersion, Constants["RevisionHashShort"]().(string)) }
43+
Constants["Version"] = func() interface{} {
44+
return mustVersionWithRevision(newVersion, Constants["RevisionHashShort"]().(string))
45+
}
3946
Constants["VersionNumber"] = func() interface{} { return newVersion.String() }
47+
Constants["RemoteInstallerVersion"] = func() interface{} { return remoteInstallerVersion.String() }
4048
Constants["Date"] = func() interface{} { return time.Now().Format(constants.DateTimeFormatRecord) }
4149
Constants["UserAgent"] = func() interface{} {
4250
return fmt.Sprintf("%s/%s; %s", constants.CommandName, Constants["Version"](), branchName)

internal/constants/version/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"github.com/blang/semver"
1212
)
1313

14-
func Detect() (semver.Version, error) {
14+
func Detect(relPath string) (semver.Version, error) {
1515
root, err := environment.GetRootPath()
1616
if err != nil {
1717
return semver.Version{}, err
1818
}
19-
versionFile := filepath.Join(root, "version.txt")
19+
versionFile := filepath.Join(root, relPath, "version.txt")
2020
_, err = os.Stat(versionFile)
2121
if err != nil {
2222
return semver.Version{}, fmt.Errorf("Could not access version.txt file at %s: %w", versionFile, err)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
"runtime"
8+
9+
"github.com/ActiveState/cli/internal/constants"
10+
"github.com/ActiveState/cli/internal/environment"
11+
"github.com/ActiveState/cli/internal/errs"
12+
"github.com/ActiveState/cli/internal/fileutils"
13+
)
14+
15+
func main() {
16+
err := run()
17+
if err != nil {
18+
fmt.Fprintf(os.Stderr, "%s error: %v", os.Args[0], errs.Join(err, ":"))
19+
}
20+
}
21+
22+
func run() error {
23+
channel := constants.BranchName
24+
version := constants.RemoteInstallerVersion
25+
26+
goos := runtime.GOOS
27+
goarch := runtime.GOARCH
28+
if len(os.Args) == 3 {
29+
goos = os.Args[1]
30+
goarch = os.Args[2]
31+
}
32+
platform := goos + "-" + goarch
33+
34+
relChannelPath := filepath.Join("remote-installer", channel, platform)
35+
relVersionedPath := filepath.Join("remote-installer", channel, version, platform)
36+
37+
buildPath := filepath.Join(environment.GetRootPathUnsafe(), "build")
38+
39+
ext := ""
40+
if goos == "windows" {
41+
ext = ".exe"
42+
}
43+
sourceFile := filepath.Join(buildPath, constants.StateRemoteInstallerCmd+ext)
44+
if !fileutils.FileExists(sourceFile) {
45+
return errs.New("source file does not exist: %s", sourceFile)
46+
}
47+
48+
fmt.Printf("Copying %s to %s\n", sourceFile, relChannelPath)
49+
if err := fileutils.CopyFile(sourceFile, filepath.Join(buildPath, relChannelPath, constants.StateRemoteInstallerCmd+ext)); err != nil {
50+
return errs.Wrap(err, "failed to copy source file to channel path")
51+
}
52+
53+
fmt.Printf("Copying %s to %s\n", sourceFile, relVersionedPath)
54+
if err := fileutils.CopyFile(sourceFile, filepath.Join(buildPath, relVersionedPath, constants.StateRemoteInstallerCmd+ext)); err != nil {
55+
return errs.Wrap(err, "failed to copy source file to version path")
56+
}
57+
58+
return nil
59+
}

0 commit comments

Comments
 (0)