mirror of
https://github.com/bitwarden/cli
synced 2025-12-28 14:03:14 +00:00
reworking gh actions into the build/release/deploy model
This commit is contained in:
195
.github/workflows/build.yml
vendored
195
.github/workflows/build.yml
vendored
@@ -4,9 +4,6 @@ on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- 'l10n_master'
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
cloc:
|
||||
@@ -23,7 +20,7 @@ jobs:
|
||||
- name: Print lines of code
|
||||
run: cloc --include-lang TypeScript,JavaScript --vcs git
|
||||
|
||||
build:
|
||||
windows:
|
||||
name: Build CLI
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
@@ -31,58 +28,47 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Windows builder
|
||||
run: choco install checksum --no-progress
|
||||
run: |
|
||||
choco install checksum --no-progress
|
||||
choco install reshack --no-progress
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '10.x'
|
||||
|
||||
- name: Install pkg-fetch
|
||||
run: |
|
||||
$fetchedUrl = "https://github.com/vercel/pkg-fetch/releases/download/v2.5/uploaded-v2.5-node-v10.4.1-win-x64"
|
||||
|
||||
New-Item -ItemType directory -Path .pkg-cache
|
||||
Invoke-RestMethod -Uri $fetchedUrl -OutFile ".pkg-cache/fetched-v10.4.1-win-x64"
|
||||
dir
|
||||
dir .pkg-cache
|
||||
|
||||
- name: Download & Install RH
|
||||
shell: pwsh
|
||||
run: |
|
||||
choco install reshack
|
||||
#Invoke-WebRequest -Uri http://www.angusj.com/resourcehacker/resource_hacker.zip -OutFile "resource_hacker.zip"
|
||||
#Expand-Archive -Path resource_hacker.zip -DestinationPath scripts/resource_hacker
|
||||
#echo "D:/a/cli/cli/scripts/resource_hacker" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
|
||||
- name: Set PACKAGE_VERSION & VER_INFO
|
||||
run: |
|
||||
$env:pkgVersion = (Get-Content -Raw -Path ./package.json | ConvertFrom-Json).version
|
||||
$env:pkgVersion = (Get-Content -Raw -Path .\src\package.json | ConvertFrom-Json).version
|
||||
echo "PACKAGE_VERSION=$env:pkgVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "WIN_PKG=$env:WIN_PKG" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "version: $env:pkgVersion"
|
||||
|
||||
dir
|
||||
if(Test-Path -Path $env:WIN_PKG) {
|
||||
Write-Host "Path exists $env:WIN_PKG"
|
||||
echo "VER_INFO=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
}
|
||||
|
||||
exit 1
|
||||
env:
|
||||
WIN_PKG: .pkg-cache/v2.5/fetched-v10.4.1-win-x64
|
||||
WIN_PKG: C:\Users\runneradmin\.pkg-cache\v2.5\fetched-v10.4.1-win-x64
|
||||
|
||||
- name: get pkg-fetch
|
||||
shell: pwsh
|
||||
run: |
|
||||
cd $HOME
|
||||
$fetchedUrl = "https://github.com/vercel/pkg-fetch/releases/download/v2.5/uploaded-v2.5-node-v10.4.1-win-x64"
|
||||
|
||||
New-Item -ItemType directory -Path .\.pkg-cache
|
||||
New-Item -ItemType directory -Path .\.pkg-cache\v2.5
|
||||
Invoke-RestMethod -Uri $fetchedUrl -OutFile ".\.pkg-cache\v2.5\fetched-v10.4.1-win-x64"
|
||||
env:
|
||||
WIN_PKG: C:\Users\runneradmin\.pkg-cache\v2.5\fetched-v10.4.1-win-x64
|
||||
|
||||
- name: Setup Version Info
|
||||
shell: pwsh
|
||||
run: ./scripts/make-versioninfo.ps1
|
||||
|
||||
- name: ResourceHacker
|
||||
- name: Resource Hacker
|
||||
shell: cmd
|
||||
run: |
|
||||
echo "ver_info: %VER_INFO%"
|
||||
if defined VER_INFO ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action delete -mask ICONGROUP,1,
|
||||
if defined VER_INFO ResourceHacker -open version-info.rc -save version-info.res -action compile
|
||||
if defined VER_INFO ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action addoverwrite -resource version-info.res
|
||||
set PATH=%PATH%;C:\Program Files (x86)\Resource Hacker
|
||||
ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action delete -mask ICONGROUP,1,
|
||||
ResourceHacker -open version-info.rc -save version-info.res -action compile
|
||||
ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action addoverwrite -resource version-info.res
|
||||
|
||||
- name: Install
|
||||
run: npm install
|
||||
@@ -90,20 +76,8 @@ jobs:
|
||||
- name: Setup sub-module
|
||||
run: npm run sub:init
|
||||
|
||||
- name: Build
|
||||
run: npm run build:prod
|
||||
|
||||
- name: Clean Build
|
||||
run: npm run clean
|
||||
|
||||
- name: Package Windows
|
||||
run: npm run package:win
|
||||
|
||||
- name: Package Mac
|
||||
run: npm run package:mac
|
||||
|
||||
- name: Package Linux
|
||||
run: npm run package:lin
|
||||
- name: Build & Package
|
||||
run: npm run dist
|
||||
|
||||
- name: Package Chocolatey
|
||||
shell: pwsh
|
||||
@@ -134,6 +108,7 @@ jobs:
|
||||
}
|
||||
|
||||
- name: Create checksums
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
checksum -f="./dist/bw-windows-${env:PACKAGE_VERSION}.zip" `
|
||||
-t sha256 | Out-File -Encoding ASCII ./dist/bw-windows-sha256-${env:PACKAGE_VERSION}.txt
|
||||
@@ -143,88 +118,56 @@ jobs:
|
||||
-t sha256 | Out-File -Encoding ASCII ./dist/bw-linux-sha256-${env:PACKAGE_VERSION}.txt
|
||||
|
||||
- name: Publish windows zip to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw-windows-${{ env.PACKAGE_VERSION }}.zip
|
||||
path: ./dist/bw-windows-${{ env.PACKAGE_VERSION }}.zip
|
||||
|
||||
- name: Publish windows checksum to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw-windows-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
path: ./dist/bw-windows-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
|
||||
- name: Publish macos zip to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw-macos-${{ env.PACKAGE_VERSION }}.zip
|
||||
path: ./dist/bw-macos-${{ env.PACKAGE_VERSION }}.zip
|
||||
|
||||
- name: Publish macos checksum to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw-macos-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
path: ./dist/bw-macos-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
|
||||
- name: Publish linux zip to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw-linux-${{ env.PACKAGE_VERSION }}.zip
|
||||
path: ./dist/bw-linux-${{ env.PACKAGE_VERSION }}.zip
|
||||
|
||||
- name: Publish linux checksum to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw-linux-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
path: ./dist/bw-linux-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
|
||||
- name: Publish Chocolatey CLI
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
|
||||
path: ./dist/chocolatey/bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
|
||||
|
||||
|
||||
publish_windows:
|
||||
name: Publish Windows
|
||||
runs-on: windows-latest
|
||||
needs: build
|
||||
if: github.event_name == 'release'
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set PACKAGE_VERSION
|
||||
run: |
|
||||
$env:pkgVersion = (Get-Content -Raw -Path ./package.json | ConvertFrom-Json).version
|
||||
echo "PACKAGE_VERSION=$env:pkgVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Download Windows Nuget
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
|
||||
path: ./dist/bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
|
||||
|
||||
- name: Setup Chocolatey
|
||||
run: choco apikey --key $env:CHOCO_API_KEY --source https://push.chocolatey.org/
|
||||
env:
|
||||
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
|
||||
|
||||
- name: Publish
|
||||
run: |
|
||||
./scripts/choco-update.ps1 -version $env:PACKAGE_VERSION
|
||||
Get-ChildItem dist
|
||||
|
||||
- name: Publish
|
||||
shell: pwsh
|
||||
run: |
|
||||
# In place of ./scripts/choco-update.ps1
|
||||
cd ./dist
|
||||
choco push
|
||||
|
||||
|
||||
# This process seems independent from the others
|
||||
build_snap:
|
||||
linux:
|
||||
name: Build Snap
|
||||
if: false
|
||||
runs-on: ubuntu-latest
|
||||
@@ -280,79 +223,15 @@ jobs:
|
||||
sudo snap remove bw
|
||||
|
||||
- name: Publish snap to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw_${{ env.PACKAGE_VERSION }}_amd64.snap
|
||||
path: ./dist/snap/bw_${{ env.PACKAGE_VERSION }}_amd64.snap
|
||||
|
||||
- name: Publish snap to GitHub
|
||||
- name: Publish snap checksum to GitHub
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bw-snap-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
path: ./dist/snap/bw-snap-sha256-${{ env.PACKAGE_VERSION }}.txt
|
||||
|
||||
|
||||
publish_snap:
|
||||
name: Publish Snap
|
||||
runs-on: ubuntu-latest
|
||||
needs: build_snap
|
||||
if: github.event_name == 'release'
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set PACKAGE_VERSION
|
||||
shell: pwsh
|
||||
run: |
|
||||
$env:pkgVersion = (Get-Content -Raw -Path ./package.json | ConvertFrom-Json).version
|
||||
echo "PACKAGE_VERSION=$env:pkgVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Install Snapcraft
|
||||
uses: samuelmeuli/action-snapcraft@v1
|
||||
with:
|
||||
snapcraft_token: ${{ secrets.SNAP_TOKEN }}
|
||||
|
||||
- name: Download snap
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bw_${{ env.PACKAGE_VERSION }}_amd64.snap
|
||||
path: ./bw_${{ env.PACKAGE_VERSION }}_amd64.snap
|
||||
|
||||
- name: Print environment
|
||||
run: |
|
||||
whoami
|
||||
snapcraft --version
|
||||
echo "GitHub ref: $GITHUB_REF"
|
||||
echo "GitHub event: $GITHUB_EVENT"
|
||||
echo "BW Package Version: $PACKAGE_VERSION"
|
||||
env:
|
||||
GITHUB_REF: ${{ github.ref }}
|
||||
GITHUB_EVENT: ${{ github.event_name }}
|
||||
|
||||
- name: Checksum Snap & Publish Snap
|
||||
run: snapcraft push ./bw_${{ env.PACKAGE_VERSION }}_amd64.snap --release stable
|
||||
|
||||
- name: Snap Logout
|
||||
run: snapcraft logout
|
||||
|
||||
|
||||
# This job is independent: it reruns 'npm run build:prod'
|
||||
# Could be moved out a level
|
||||
publish_npm:
|
||||
name: Publish NPM
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: github.event_name == 'release'
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup NPM
|
||||
shell: pwsh
|
||||
run: |
|
||||
"//registry.npmjs.org/:_authToken=${env:NPM_TOKEN}" | Out-File ".npmrc" -Encoding UTF8
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Publish NPM
|
||||
run: npm run publish:npm
|
||||
|
||||
Reference in New Issue
Block a user