mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
initial commit of the new GH Actions workflow
This commit is contained in:
parent
0330641a14
commit
336c41c054
168
.github/workflows/build.yml
vendored
Normal file
168
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
name: build & publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
# push:
|
||||||
|
# branches-ignore:
|
||||||
|
# - 'l10n_master'
|
||||||
|
# release:
|
||||||
|
# types:
|
||||||
|
# - published
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cloc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up cloc
|
||||||
|
run: |
|
||||||
|
apt update
|
||||||
|
apt -y install cloc
|
||||||
|
|
||||||
|
- name: Print lines of code
|
||||||
|
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
|
||||||
|
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build CLI
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Node
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: '10.x'
|
||||||
|
|
||||||
|
- name: Setup & Build
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm sub:init
|
||||||
|
npm dist
|
||||||
|
|
||||||
|
- name: Zip
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
7z a ./dist/bw-windows-%PACKAGE_VERSION%.zip ./dist/windows/bw.exe
|
||||||
|
7z a ./dist/bw-macos-%PACKAGE_VERSION%.zip ./dist/macos/bw
|
||||||
|
7z a ./dist/bw-linux-%PACKAGE_VERSION%.zip ./dist/linux/bw
|
||||||
|
|
||||||
|
- name: Version Test
|
||||||
|
run: |
|
||||||
|
Expand-Archive -Path "./dist/bw-windows-${env:PACKAGE_VERSION}.zip" -DestinationPath "./test/windows"
|
||||||
|
$testVersion = Invoke-Expression '& ./test/windows/bw.exe -v'
|
||||||
|
if($testVersion -ne $env:PACKAGE_VERSION) {
|
||||||
|
Throw "Version test failed."
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Package & Create checksums
|
||||||
|
run: |
|
||||||
|
.\scripts\choco-pack.ps1
|
||||||
|
|
||||||
|
checksum -f="./dist/bw-windows-${env:PACKAGE_VERSION}.zip" `
|
||||||
|
-t sha256 | Out-File -Encoding ASCII ./dist/bw-windows-sha256-${env:PACKAGE_VERSION}.txt
|
||||||
|
checksum -f="./dist/bw-macos-${env:PACKAGE_VERSION}.zip" `
|
||||||
|
-t sha256 | Out-File -Encoding ASCII ./dist/bw-macos-sha256-${env:PACKAGE_VERSION}.txt
|
||||||
|
checksum -f="./dist/bw-linux-${env:PACKAGE_VERSION}.zip" `
|
||||||
|
-t sha256 | Out-File -Encoding ASCII ./dist/bw-linux-sha256-${env:PACKAGE_VERSION}.txt
|
||||||
|
|
||||||
|
- name: Publish to GitHub
|
||||||
|
run: |
|
||||||
|
Write-Host "<stub for publishing cli zips and checksums to release>"
|
||||||
|
Write-Host .\dist\bw-windows-${env:PACKAGE_VERSION}.zip
|
||||||
|
Write-Host .\dist\bw-macos-${env:PACKAGE_VERSION}.zip
|
||||||
|
Write-Host .\dist\bw-linux-${env:PACKAGE_VERSION}.zip
|
||||||
|
Write-Host .\dist\bw-windows-sha256-${env:PACKAGE_VERSION}.txt
|
||||||
|
Write-Host .\dist\bw-macos-sha256-${env:PACKAGE_VERSION}.txt
|
||||||
|
Write-Host .\dist\bw-linux-sha256-${env:PACKAGE_VERSION}.txt
|
||||||
|
Write-Host .\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: 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
|
||||||
|
|
||||||
|
|
||||||
|
publish_snap:
|
||||||
|
name: Publish Snap
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Snapcraft
|
||||||
|
uses: samuelmeuli/action-snapcraft@v1
|
||||||
|
with:
|
||||||
|
snapcraft_token: ${{ secrets.SNAP_TOKEN }}
|
||||||
|
|
||||||
|
- name: Print environment
|
||||||
|
run: |
|
||||||
|
whoami
|
||||||
|
snapcraft --version
|
||||||
|
echo "GitHub ref: $GITHUB_REF"
|
||||||
|
echo "GitHub event: $GITHUB_EVENT"
|
||||||
|
env:
|
||||||
|
GITHUB_REF: ${{ github.ref }}
|
||||||
|
GITHUB_EVENT: ${{ github.event_name }}
|
||||||
|
|
||||||
|
- name: Install Snap
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
./scripts/snap-build.ps1 -version $env:PACKAGE_VERSION
|
||||||
|
snap install ./dist/snap/bw*.snap --dangerous
|
||||||
|
|
||||||
|
- name: Test Snap
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$testVersion = Invoke-Expression '& bw -v'
|
||||||
|
if($testVersion -ne $env:PACKAGE_VERSION) {
|
||||||
|
Throw "Version test failed."
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Cleanup Test & Update Snap for Publish
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
snap remove bw
|
||||||
|
./scripts/snap-update.ps1
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
echo "<stub for publishing snap to github release>"
|
||||||
|
echo "./dist/snap/bw_${PACKAGE_VERSION}_amd64.snap"
|
||||||
|
|
||||||
|
- name: Snap Logout
|
||||||
|
run: snapcraft logout
|
||||||
|
|
||||||
|
|
||||||
|
publish_npm:
|
||||||
|
name: Publish NPM
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
steps:
|
||||||
|
- 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
|
Loading…
Reference in New Issue
Block a user