Skip to content

skip e2e

skip e2e #778

name: CI/CT/CD test and nightly release
# env:
# name: staging_environment
# concurrency: staging_environment
on:
schedule:
- cron: "50 10 * * *"
pull_request:
push:
paths:
- "**.js"
- "!**/release-nightly.yml"
- "!patches/**"
- "!public/**"
- "!wix/**"
- "!snapcraft/**"
- "!developer/**"
- "!build-scripts/**"
- "!test/**"
- "dist/**"
- "release.json"
branches: [main]
jobs:
nightly_job:
runs-on: ${{ matrix.os }}
if: |
!contains(github.event.head_commit.message , 'skip workflow') && !contains(github.event.head_commit.message , 'Merge branch')
outputs:
tag-name: ${{ steps.unify.outputs.tag-name }}
release-name: ${{ steps.unify.outputs.release-name }}
package-name: ${{ steps.unify.outputs.package-name }}
isRunAppium: ${{ steps.check.outputs.isRunAppium }}
isBuildUniversal: ${{ steps.check.outputs.isBuildUniversal }}
isModifyReleaseJson: ${{ steps.unify.outputs.isModifyReleaseJson }}
repository: ${{ steps.check.outputs.repository }}
display-name: ${{ steps.slug.outputs.display-name }}
file-name-lower: ${{ steps.slug.outputs.file-name-lower }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node-version: [16]
include:
- os: windows-latest
node-version: 16
fail-fast: false
environment:
name: CICD
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }}
GITHUB_PAT: ${{ secrets.PAT }}
CERT_DATA: ${{ secrets.APPLE_CERT_DATA }}
CERT_PASS: ${{ secrets.APPLE_CERT_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ASP: ${{ secrets.APPLE_ASP }}
GOOGLE_EMAIL_USERNAME: ${{ secrets.GOOGLE_EMAIL_USERNAME }}
GOOGLE_EMAIL_PASSWORD: ${{ secrets.GOOGLE_EMAIL_PASSWORD }}
EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
PHONE_NUMBER_ACCOUNT: ${{ secrets.PHONE_NUMBER_ACCOUNT }}
PHONE_NUMBER_TOKEN: ${{ secrets.PHONE_NUMBER_TOKEN }}
TEST_EMAIL_DOMAIN: ${{ secrets.TEST_EMAIL_DOMAIN }}
TEST1_EMAIL: ${{ secrets.TEST1_EMAIL }}
TEST2_EMAIL: ${{ secrets.TEST2_EMAIL }}
TEST3_EMAIL: ${{ secrets.TEST3_EMAIL }}
TEST1_PHONE_NUMBER: ${{ secrets.TEST1_PHONE_NUMBER }}
TEST2_PHONE_NUMBER: ${{ secrets.TEST2_PHONE_NUMBER }}
TEST3_PHONE_NUMBER: ${{ secrets.TEST3_PHONE_NUMBER }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
TEST_RESET_PASSWORD: ${{ secrets.TEST_RESET_PASSWORD }}
OAUTH_ACCOUNT_PASSWORD: ${{ secrets.OAUTH_ACCOUNT_PASSWORD }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
steps:
- name: Get short SHA 🔑
id: sha
run: |
echo "sha7=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout ${{ steps.sha.outputs.sha7 }} ⬇️
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Get app name
id: slug
run: |
DISPLAYNAME=$(cat developer/app.js | perl -wnE"say for /(?<=displayName\:\s)\'?.*\'?(?=,)/gm")
APPNAME=$(cat developer/app.js | perl -wnE"say for /(?<=const\sAPP\s=\s\')[a-zA-Z]+/gm")
FILENAME=$(cat developer/app.js | perl -wnE"say for /(?<=fileName\:\s)\'?.*\'?(?=,)/gm")
echo ${APPNAME}
echo ${DISPLAYNAME}
echo ${FILENAME}
echo "app-name=${APPNAME}" >> $GITHUB_OUTPUT
echo "app-name-lower=$(echo ${APPNAME} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
if [[ ${DISPLAYNAME} = "APP" ]] ; \
then echo "display-name=${APPNAME}" >> $GITHUB_OUTPUT ; \
echo "display-name-lower=$(echo ${APPNAME} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT ; \
else DISPLAYNAME=$(echo ${DISPLAYNAME} | sed "s/'//g") ; \
echo "display-name=${DISPLAYNAME}" >> $GITHUB_OUTPUT ; \
echo "display-name-lower=$(echo ${DISPLAYNAME} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT ; \
fi
if [[ ${FILENAME} = "APP" ]] ; \
then echo "file-name=${APPNAME}" >> $GITHUB_OUTPUT ; \
echo "file-name-lower=$(echo ${APPNAME} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT ; \
else FILENAME=$(echo ${FILENAME} | sed "s/'//g") ; \
echo "file-name=${FILENAME}" >> $GITHUB_OUTPUT ; \
echo "file-name-lower=$(echo ${FILENAME} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT ; \
fi
shell: bash
- uses: actions/setup-python@v5
if: runner.os == 'macOS'
with:
python-version: '3.8'
- name: Setup Node.js ${{ matrix.node-version }} 📮
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
registry-url: "https://npm.pkg.github.com"
scope: "@zeeis"
- name: Get message
id: vars
run: |
echo "date=$(TZ=UTC-8 git log -1 --date=format-local:"%Y%m%d%H%M" --format="%cd")" >> $GITHUB_OUTPUT
echo "event-name=${{ github.event_name }}" >> $GITHUB_OUTPUT
echo "download-tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
if [[ ${{ matrix.os }} = "ubuntu-latest" ]] ; \
then echo "system=ubuntu" >> $GITHUB_OUTPUT ; \
echo "package=${{ steps.slug.outputs.display-name }}-linux-x64" >> $GITHUB_OUTPUT ; \
elif [[ ${{ matrix.os }} = "macos-latest" ]] ; \
then echo "system=macos" >> $GITHUB_OUTPUT ; \
echo "package=${{ steps.slug.outputs.display-name }}-darwin-x64" >> $GITHUB_OUTPUT ; \
elif [[ ${{ matrix.os }} = "windows-latest" ]] ; \
then echo "system=windows" >> $GITHUB_OUTPUT ; \
echo "package=${{ steps.slug.outputs.display-name }}-win32-x64" >> $GITHUB_OUTPUT ; \
fi
export COMMIT_HEAD=$(git log -1 --pretty=%B | perl -wnE'say for /^\w+/gm')
if [[ "$COMMIT_HEAD" = "Merge" ]] ; \
then export MODIFIED_FILE_LIST=$(git show --pretty="format:" --name-only -2) ; \
else export MODIFIED_FILE_LIST=$(git show --pretty="format:" --name-only) ; \
fi
MODIFIED_FILE_LIST=$(echo $MODIFIED_FILE_LIST | tr '\n' ' ')
echo "MODIFIED_FILE_LIST=$MODIFIED_FILE_LIST" >> "$GITHUB_ENV"
# EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
# echo "MODIFIED_FILE_LIST<<$EOF" >> "$GITHUB_ENV"
# echo "$MODIFIED_FILE_LIST" >> "$GITHUB_ENV"
# echo "$EOF" >> "$GITHUB_ENV"
shell: bash
- name: Get release.json property
id: release
if: contains(env.MODIFIED_FILE_LIST, 'release.json')
run: |
CONTENT=$(cat ./release.json)
TARGET_TAG_NAME=$(echo "$CONTENT" | perl -wnE"say for /(?<=targetTagName\"\:\s\").*(?=\",)/gm")
NEW_TAG_NAME=$(echo "$CONTENT" | perl -wnE"say for /(?<=newTagName\"\:\s\").*(?=\")/gm")
echo "target-tag-name=${TARGET_TAG_NAME}"
echo "new-tag-name=${NEW_TAG_NAME}"
echo "target-tag-name=${TARGET_TAG_NAME}" >> $GITHUB_OUTPUT
echo "new-tag-name=${NEW_TAG_NAME}" >> $GITHUB_OUTPUT
shell: bash
- name: Get package.json version
id: version
uses: notiz-dev/github-action-json-property@release
with:
path: "package.json"
prop_path: "version"
- name: Checkout release.json target tag
id: checkout
if: contains(env.MODIFIED_FILE_LIST, 'release.json')
run: |
git checkout ${{ steps.release.outputs.target-tag-name }}
git show --name-only
shell: bash
- name: Get unpackaged/version.json property
id: unpackaged
run: |
CONTENT=$(cat ./dist/electron/UnPackaged/version.json)
PACKAGE_VERSION=$(echo "$CONTENT" | perl -wnE"say for /(?<=packageVer\"\:\s\").*(?=\")/gm")
echo "package-version=${PACKAGE_VERSION}"
echo "package-version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
shell: bash
# stable version x.y.z+1
- name: Get UnstableVersion
id: unstable
run: |
echo "unstable-version=$(echo ${{ steps.unpackaged.outputs.package-version }} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}')" >> $GITHUB_OUTPUT
shell: bash
# after git checkout
- name: Get last commit date \ today all commit message
if: contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json')
id: nightly
run: |
echo "commit-sha7=$(git log -1 --pretty=%B --author="Alphabiz-Team" | perl -wnE'say for /(?<=-)\w{7,8}(?=\s)|^\w{7,8}(?=\s)/g')" >> $GITHUB_OUTPUT
export DESCRIBE=$(cat github-describe/github-describe.txt)
echo "$DESCRIBE"
DESCRIBE=$(head -n 1 github-describe/github-describe.txt)
echo "DESCRIBE=$DESCRIBE" >> "$GITHUB_ENV"
# echo "DESCRIBE<<EOF" >> "$GITHUB_ENV"
# echo "$DESCRIBE" >> "$GITHUB_ENV"
# echo "EOF" >> "$GITHUB_ENV"
shell: bash
# This step for unify the tag name
# nightly-release use tag_name: $packageJsonVersion-internal/nightly-$dateTime-$commitId
# official-release use tag_name: ./release.json property newTagName
- name: Unified Tag format
if: contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json')
id: unify
run: |
if ${{ contains(env.MODIFIED_FILE_LIST, 'release.json') }} ; \
then echo "tag-name=${{ steps.release.outputs.new-tag-name }}" >> $GITHUB_OUTPUT ; \
echo "isModifyReleaseJson=1" >> $GITHUB_OUTPUT ; \
if ${{ contains(steps.release.outputs.new-tag-name, 'nightly') }} ; \
then echo "release-name=${{ steps.release.outputs.new-tag-name }}-${{ steps.nightly.outputs.commit-sha7 }}" >> $GITHUB_OUTPUT ; \
else echo "release-name=${{ steps.release.outputs.new-tag-name }}-${{ steps.nightly.outputs.commit-sha7 }}" >> $GITHUB_OUTPUT ; \
fi
echo "package-name=${{ steps.release.outputs.new-tag-name }}" >> $GITHUB_OUTPUT ; \
else echo "tag-name=${{ steps.unstable.outputs.unstable-version }}-nightly-${{ steps.vars.outputs.date }}" >> $GITHUB_OUTPUT ; \
echo "release-name=${{ steps.unstable.outputs.unstable-version }}-nightly-${{ steps.vars.outputs.date }}-${{ steps.nightly.outputs.commit-sha7 }}" >> $GITHUB_OUTPUT ; \
echo "package-name=${{ steps.unstable.outputs.unstable-version }}-nightly-${{ steps.vars.outputs.date }}" >> $GITHUB_OUTPUT ; \
echo "isModifyReleaseJson=0" >> $GITHUB_OUTPUT ; \
fi
shell: bash
# this step checkout all output
- name: Checkout vars-date ${{ steps.vars.outputs.date }} ⬇️
id: check
run: |
echo "isBuildUniversal=0" >> $GITHUB_OUTPUT
echo "repo-name: ${{ github.repository }}"
echo "repository=${{ github.repository }}" >> $GITHUB_OUTPUT
echo "slug----------------------"
echo "app-name: ${{ steps.slug.outputs.app-name }}"
echo "app-name-lower: ${{ steps.slug.outputs.app-name-lower }}"
echo "display-name: ${{ steps.slug.outputs.display-name }}"
echo "display-name-lower: ${{ steps.slug.outputs.display-name-lower }}"
echo "file-name: ${{ steps.slug.outputs.file-name }}"
echo "file-name-lower: ${{ steps.slug.outputs.file-name-lower }}"
echo "vars----------------------"
echo "run workflow date: ${{ steps.vars.outputs.date }}"
echo "event_name: ${{ steps.vars.outputs.event-name }}"
echo "download-tag: ${{ steps.vars.outputs.download-tag }}"
echo "event.head_commit.message: ${{ github.event.head_commit.message }}"
echo "system: ${{ steps.vars.outputs.system }}"
echo "package: ${{ steps.vars.outputs.package }}"
echo "release----------------------"
echo "target-tag-name: ${{ steps.release.outputs.target-tag-name }}"
echo "new-tag-name: ${{ steps.release.outputs.new-tag-name }}"
echo "version----------------------"
echo "package.json version: ${{ steps.version.outputs.prop }}"
echo "unpackaged----------------------"
echo "unpackage.version: ${{ steps.unpackaged.outputs.package-version }}"
echo "unstable----------------------"
echo "unstable-version: ${{ steps.unstable.outputs.unstable-version }}"
echo "----------------------"
echo "MODIFIED_FILE_LIST: ${{ env.MODIFIED_FILE_LIST }}"
if ${{ contains(env.MODIFIED_FILE_LIST, 'release.json') }} ; \
then echo "isRunAppium=1" >> $GITHUB_OUTPUT ; \
else echo "isRunAppium=0" >> $GITHUB_OUTPUT ; \
fi
echo "unify----------------------"
echo "tag-name: ${{ steps.unify.outputs.tag-name }}"
echo "release-name: ${{ steps.unify.outputs.release-name }}"
echo "package-name: ${{ steps.unify.outputs.package-name }}"
echo "nightly----------------------"
echo "commit-sha7: ${{ steps.nightly.outputs.commit-sha7 }}"
shell: bash
- name: Install dependencies 👨🏻‍💻
uses: nick-fields/retry@v2
with:
timeout_seconds: 600
max_attempts: 2
shell: bash
retry_on: error
command: yarn
on_retry_command: rm -rf C:/Users/runneradmin/AppData/Local/node-gyp/
- name: Install UnPackaged 👨🏻‍💻
uses: nick-fields/retry@v2
with:
timeout_seconds: 600
max_attempts: 2
shell: bash
retry_on: error
command: yarn unpackaged
on_retry_command: rm -rf C:/Users/runneradmin/AppData/Local/node-gyp/
# - name: setDisplay for windows
# if: contains(steps.vars.outputs.system, 'windows')
# run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
# shell: powershell
- name: screen resolution(For Win)
if: runner.os == 'Windows'
run: |
Set-DisplayResolution -Width 1920 -Height 1080 -Force
shell: powershell
- name: screen resolution(For Mac)
if: runner.os == 'macOS'
run: |
system_profiler SPDisplaysDataType | grep Resolution
"/Library/Application Support/VMware Tools/vmware-resolutionSet" 2560 1440
system_profiler SPDisplaysDataType | grep Resolution
- name: main E2E Test for Electron 🧪
if: "!contains(github.event.head_commit.message, 'skip e2e')"
run: |
export REPO=alphabiz
yarn test:e2e:electron:main
unset REPO
shell: bash
- name: wallet E2E Test for Electron 🧪
if: "!contains(github.event.head_commit.message, 'skip e2e')"
run: |
export REPO=alphabiz
yarn test:e2e:electron:wallet
unset REPO
shell: bash
- name: E2E Test 🧪
if: |
!contains(github.event.head_commit.message, 'skip e2e') && !contains(steps.vars.outputs.system, 'windows')
&& github.repository == 'tanshuai/alphabiz'
run: yarn test:e2e:ci
- name: Upload Test Results 🗃
if: always()
uses: actions/upload-artifact@v3
with:
name: "${{ matrix.os }}-output"
path: test/output/**
#后面的step晚上运行 或 正式发布
- name: Get recommends from github
if: |
(contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json'))
&& steps.slug.outputs.app-name == 'Alphabiz'
run: |
curl -H 'Authorization: token ${{ secrets.PAT }}' \
-L "https://raw.githubusercontent.com/tanshuai/alpha.biz/main/static/recommends/v0.2.1.txt" \
> public/recommends.txt
shell: bash
- name: Run electron-packager 📦
if: contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json')
run: |
if ${{ contains(env.MODIFIED_FILE_LIST, 'release.json') }} ; \
then if ${{ contains(steps.release.outputs.new-tag-name, 'nightly') }} ; \
then yarn node update-version.js --newTag ${{ steps.unify.outputs.tag-name }} --SHA7 ${{ steps.sha.outputs.sha7 }} --buildTime ${{ steps.vars.outputs.date }} ; \
else yarn node update-version.js --newTag ${{ steps.unify.outputs.tag-name }} --SHA7 ${{ steps.sha.outputs.sha7 }} --buildTime ${{ steps.vars.outputs.date }} --stable; \
fi
else yarn node update-version.js --buildTime ${{ steps.vars.outputs.date }} ; \
fi
yarn packager
shell: bash
- name: Setup coreutils
if: |
(contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json'))
&& contains(steps.vars.outputs.system, 'macos')
&& env.CERT_PASS != ''
run: brew install coreutils
- name: Import cert
if: |
(contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json'))
&& contains(steps.vars.outputs.system, 'macos')
&& env.CERT_PASS != ''
env:
CERT_DATA: ${{ secrets.APPLE_CERT_DATA }}
CERT_PASS: ${{ secrets.APPLE_CERT_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
# Export certs
echo "$CERT_DATA" | base64 --decode > /tmp/certs.p12
echo "exported certs.p12 to /tmp/certs.p12"
# Create keychain
security create-keychain -p actions macos-build.keychain
security default-keychain -s macos-build.keychain
security unlock-keychain -p actions macos-build.keychain
security set-keychain-settings -t 3600 -u macos-build.keychain
# Import certs to keychain
security import /tmp/certs.p12 -k ~/Library/Keychains/macos-build.keychain -P "$CERT_PASS" -T /usr/bin/codesign -T /usr/bin/productsign
echo "imported certs"
# Key signing
security set-key-partition-list -S apple-tool:,apple: -s -k actions macos-build.keychain
# Verify keychain things
echo "Verifying keychain..."
security find-identity -v macos-build.keychain | grep "$APPLE_TEAM_ID" | grep "Developer ID Application"
security find-identity -v macos-build.keychain | grep "$APPLE_TEAM_ID" | grep "Developer ID Installer"
echo "Keychain verified"
- name: Pack app 📦
if: contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json')
run: |
if [[ ${{ steps.vars.outputs.system }} == *macos* ]] && [[ -n "${{ env.APPLE_ID }}" ]]; then
export PLATFORM=darwin
export BUILD_PLATFORM=darwin
export ARCH=x64
export BUILD_ARCH=x64
export APP_BUNDLE_ID=org.alpha.biz
export CERT_PASS="${{ secrets.APPLE_CERT_PASSWORD }}"
export APPLE_TEAM_ID="${{ secrets.APPLE_TEAM_ID }}"
export APPLE_DISTRIBUTION_KEY="Developer ID Application"
export VERSION="${{ steps.unify.outputs.tag-name }}"
export BUILD_VERSION="${{ steps.unify.outputs.tag-name }}"
export APP="${{ steps.slug.outputs.display-name }}"
export APPLE_ID="${{ secrets.APPLE_ID }}"
export APPLE_ASP="${{ secrets.APPLE_ASP }}"
fi
export PATH=$PATH:/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin
yarn make
if [[ ${{ steps.vars.outputs.system }} == *macos* ]] && [[ -n "${{ env.APPLE_ID }}" ]]; then
SIGN_APP="./out/$APP-$PLATFORM-$ARCH/$APP.app"
echo "$SIGN_APP"
echo "$APP"
# Throw error if file does not exist
if [ ! -e "$SIGN_APP" ]; then
echo "$SIGN_APP does not exist!"
exit 5
fi
# ./build-scripts/macos/pkg/sign.sh
# Verify the code signature
echo "Verifying..."
codesign -v -vvv "$SIGN_APP"
pkgutil --check-signature "$SIGN_APP"
echo "Signature verified."
fi
shell: bash
- name: Create And Sign Pkg
if: |
(contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json'))
&& contains(steps.vars.outputs.system, 'macos')
&& env.CERT_PASS != ''
continue-on-error: true # If sign failed, just continue for normal builds
env:
CERT_DATA: ${{ secrets.APPLE_CERT_DATA }}
CERT_PASS: ${{ secrets.APPLE_CERT_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_DISTRIBUTION_KEY: "Developer ID Application"
APPLE_INSTALLER_KEY: "Developer ID Installer"
VERSION: ${{ steps.unify.outputs.tag-name }}
BUILD_VERSION: ${{ steps.unify.outputs.tag-name }}
PLATFORM: darwin
BUILD_PLATFORM: darwin
ARCH: x64
BUILD_ARCH: x64
APP: "${{ steps.slug.outputs.display-name }}"
APP_BUNDLE_ID: org.alpha.biz
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ASP: ${{ secrets.APPLE_ASP }}
run: |
SIGN_FILE="out/installers/${{ env.VERSION }}/${{ env.APP }}_${{ env.PLATFORM }}_${{ env.VERSION }}.pkg"
UNSIGNED_FILE="out/installers/${{ env.VERSION }}/${{ env.APP }}_${{ env.PLATFORM }}_${{ env.VERSION }}_unsigned.pkg"
echo "Build pkg"
./build-scripts/macos/pkg/build.sh
echo "Check pkg size"
du -h "$SIGN_FILE"
echo "Remove unsigned pkg"
if [ -e "$UNSIGNED_FILE" ]; then
rm "$UNSIGNED_FILE"
fi
echo "Notarizing dmg..."
SIGNED_DMG="out/installers/$VERSION/${{ steps.slug.outputs.app-name-lower }}-$ARCH-$VERSION.dmg"
xcrun notarytool submit "$SIGNED_DMG" -v --apple-id "$APPLE_ID" --password "$APPLE_ASP" --team-id "$APPLE_TEAM_ID" -f json --wait
xcrun stapler staple "$SIGNED_DMG"
echo "Finish notarizing dmg"
- name: Package for ${{ steps.vars.outputs.system }}-${{ steps.unify.outputs.tag-name }} Release 🗜️
if: contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json')
run: 7z a -t7z -mx=9 "./out/installers/${{ steps.unify.outputs.tag-name }}/${{ steps.slug.outputs.file-name-lower }}-${{ steps.unify.outputs.package-name }}-${{ steps.vars.outputs.system }}.7z" "./dist/electron/${{ steps.vars.outputs.package }}"
- name: Generate shasum files
run: node build-scripts/common/shasum.js out/installers/${{ steps.unify.outputs.tag-name }}
shell: bash
continue-on-error: true # Missing .sha files is still ok
- name: Release ${{ steps.slug.outputs.file-name-lower }}-${{ steps.unify.outputs.package-name }}-${{ steps.vars.outputs.system }} to GitHub 📰
if: |
(contains(steps.vars.outputs.event-name, 'schedule') || contains(env.MODIFIED_FILE_LIST, 'release.json')) &&
(matrix.os != 'macos-latest' || contains(steps.check.outputs.isBuildUniversal, '0'))
uses: softprops/action-gh-release@v1
with:
prerelease: true
name: ${{ steps.slug.outputs.file-name-lower }}-${{ steps.unify.outputs.release-name }}
tag_name: ${{ steps.unify.outputs.tag-name }}
body: ${{ env.DESCRIBE }}
files: |
./out/installers/${{ steps.unify.outputs.tag-name }}/**
- name: public describe to Twitter
if: |
contains(steps.vars.outputs.event-name, 'schedule') && matrix.os == 'ubuntu-latest'
&& steps.slug.outputs.app-name == 'Alphabiz'
run: yarn node publicTwitter.js
strat_instances_job:
needs: nightly_job
runs-on: ${{ matrix.os }}
if: |
(contains(github.event_name, 'schedule') || contains(needs.nightly_job.outputs.isModifyReleaseJson, '1')) &&
contains(needs.nightly_job.outputs.isBuildUniversal, '1')
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16]
fail-fast: false
environment:
name: CICD
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }}
GITHUB_PAT: ${{ secrets.PAT }}
AWS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Get short SHA 🔑
id: sha
run: |
echo "sha7=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout ${{ steps.sha.outputs.sha7 }} ⬇️
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Setup Node.js ${{ matrix.node-version }} 📮
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
registry-url: "https://npm.pkg.github.com"
scope: "@zeeis"
- name: Install dependencies 👨🏻‍💻
uses: nick-fields/retry@v2
with:
timeout_seconds: 600
max_attempts: 2
shell: bash
retry_on: error
command: yarn
on_retry_command: rm -rf C:/Users/runneradmin/AppData/Local/node-gyp/
# - name: start EC2 Instances
# run: yarn node ./test/scripts/EC2.js --allocate
# shell: bash
release_dmg_job:
needs: [nightly_job, strat_instances_job]
if: |
(contains(github.event_name, 'schedule') || contains(needs.nightly_job.outputs.isModifyReleaseJson, '1')) &&
contains(needs.nightly_job.outputs.isBuildUniversal, '1')
timeout-minutes: 120
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [16]
os: [macos-m1-runner]
environment:
name: CICD
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }}
GITHUB_PAT: ${{ secrets.PAT }}
steps:
- name: Get short SHA 🔑
id: sha
run: |
echo "sha7=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout ${{ steps.sha.outputs.sha7 }} ⬇️
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Get message
id: vars
run: |
echo "system=macos" >> $GITHUB_OUTPUT
echo "date=$(TZ=UTC-8 git log -1 --date=format-local:"%Y%m%d%H%M" --format="%cd")" >> $GITHUB_OUTPUT
- name: Get release.json property
id: release
if: contains(needs.nightly_job.outputs.isModifyReleaseJson, '1')
run: |
CONTENT=$(cat ./release.json)
TARGET_TAG_NAME=$(echo "$CONTENT" | perl -wnE"say for /(?<=targetTagName\"\:\s\").*(?=\",)/gm")
NEW_TAG_NAME=$(echo "$CONTENT" | perl -wnE"say for /(?<=newTagName\"\:\s\").*(?=\")/gm")
echo "target-tag-name=${TARGET_TAG_NAME}"
echo "new-tag-name=${NEW_TAG_NAME}"
echo "target-tag-name=${TARGET_TAG_NAME}" >> $GITHUB_OUTPUT
echo "new-tag-name=${NEW_TAG_NAME}" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout release.json target tag
id: checkout
if: contains(needs.nightly_job.outputs.isModifyReleaseJson, '1')
run: |
git checkout ${{ steps.release.outputs.target-tag-name }}
git show --name-only
shell: bash
- name: Install dependencies 👨🏻‍💻
uses: nick-fields/retry@v2
with:
timeout_seconds: 600
max_attempts: 2
shell: bash
retry_on: error
command: yarn
on_retry_command: rm -rf C:/Users/runneradmin/AppData/Local/node-gyp/
- name: Prepare packing env
run: |
if ${{ contains(needs.nightly_job.outputs.isModifyReleaseJson, '1') }} ; \
then if ${{ contains(steps.release.outputs.new-tag-name, 'nightly') }} ; \
then yarn node update-version.js --newTag ${{needs.nightly_job.outputs.tag-name}} --SHA7 ${{ steps.sha.outputs.sha7 }} --buildTime ${{ steps.vars.outputs.date }} ; \
else yarn node update-version.js --newTag ${{needs.nightly_job.outputs.tag-name}} --SHA7 ${{ steps.sha.outputs.sha7 }} --buildTime ${{ steps.vars.outputs.date }} --stable; \
fi
else yarn node update-version.js --buildTime ${{ steps.vars.outputs.date }} ; \
fi
node ./build-scripts/macos/get-env.js --darwin
cp ./build-scripts/macos/.env ./.env
shell: bash
- name: Pack app 📦
run: |
./build-scripts/macos/app/build.sh
- name: Pack dmg 📦
run: |
./build-scripts/macos/dmg/build.sh
- name: Pack 7z 📦
run: |
7z a -t7z -mx=9 "./out/installers/${{needs.nightly_job.outputs.tag-name}}/${{ needs.nightly_job.outputs.file-name-lower }}-arm64-${{needs.nightly_job.outputs.tag-name}}-macos.7z" "./dist/electron/${{ needs.nightly_job.outputs.display-name }}-darwin-arm64"
7z a -t7z -mx=9 "./out/installers/${{needs.nightly_job.outputs.tag-name}}/${{ needs.nightly_job.outputs.file-name-lower }}-x64-${{needs.nightly_job.outputs.tag-name}}-macos.7z" "./dist/electron/${{ needs.nightly_job.outputs.display-name }}-darwin-x64"
7z a -t7z -mx=9 "./out/installers/${{needs.nightly_job.outputs.tag-name}}/${{ needs.nightly_job.outputs.file-name-lower }}-universal-${{needs.nightly_job.outputs.tag-name}}-macos.7z" "./dist/electron/${{ needs.nightly_job.outputs.display-name }}-darwin-universal"
- name: Generate shasum files
run: node build-scripts/common/shasum.js out/installers/${{needs.nightly_job.outputs.tag-name}}
shell: bash
continue-on-error: true # Missing .sha files is still ok
- name: Release macos dmg to GitHub 📰
uses: softprops/action-gh-release@v1
with:
prerelease: true
name: ${{ needs.nightly_job.outputs.file-name-lower }}-${{ needs.nightly_job.outputs.release-name }}
tag_name: ${{needs.nightly_job.outputs.tag-name}}
files: |
./out/installers/${{ needs.nightly_job.outputs.tag-name }}/**
- name: Upload Test Results 🗃
if: always()
uses: actions/upload-artifact@v3
with:
name: "build-dmg-output"
path: build.log
release_snapcraft_job:
needs: [nightly_job]
runs-on: ${{ matrix.os }}
if: contains(github.event_name, 'schedule') || contains(needs.nightly_job.outputs.isModifyReleaseJson, '1')
strategy:
matrix:
os: [ubuntu-20.04]
node-version: [16]
fail-fast: false
environment:
name: CICD
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }}
GITHUB_PAT: ${{ secrets.PAT }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
steps:
- name: Get short SHA 🔑
id: sha
run: |
echo "sha7=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout ${{ steps.sha.outputs.sha7 }} ⬇️
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Setup Node.js ${{ matrix.node-version }} 📮
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
registry-url: "https://npm.pkg.github.com"
scope: "@zeeis"
- name: Get message
id: vars
run: |
echo "date=$(TZ=UTC-8 git log -1 --date=format-local:"%Y%m%d%H%M" --format="%cd")" >> $GITHUB_OUTPUT
if [[ ${{ matrix.os }} = "ubuntu-latest" ]] ; \
then echo "system=ubuntu" >> $GITHUB_OUTPUT ; \
echo "package=${{ steps.slug.outputs.display-name }}-linux-x64" >> $GITHUB_OUTPUT ; \
elif [[ ${{ matrix.os }} = "macos-latest" ]] ; \
then echo "system=macos" >> $GITHUB_OUTPUT ; \
echo "package=${{ steps.slug.outputs.display-name }}-darwin-x64" >> $GITHUB_OUTPUT ; \
elif [[ ${{ matrix.os }} = "windows-latest" ]] ; \
then echo "system=windows" >> $GITHUB_OUTPUT ; \
echo "package=${{ steps.slug.outputs.display-name }}-win32-x64" >> $GITHUB_OUTPUT ; \
fi
shell: bash
- name: Get release.json property
id: release
if: contains(needs.nightly_job.outputs.isModifyReleaseJson, '1')
run: |
CONTENT=$(cat ./release.json)
TARGET_TAG_NAME=$(echo "$CONTENT" | perl -wnE"say for /(?<=targetTagName\"\:\s\").*(?=\",)/gm")
NEW_TAG_NAME=$(echo "$CONTENT" | perl -wnE"say for /(?<=newTagName\"\:\s\").*(?=\")/gm")
echo "target-tag-name=${TARGET_TAG_NAME}"
echo "new-tag-name=${NEW_TAG_NAME}"
echo "target-tag-name=${TARGET_TAG_NAME}" >> $GITHUB_OUTPUT
echo "new-tag-name=${NEW_TAG_NAME}" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout release.json target tag
id: checkout
if: contains(needs.nightly_job.outputs.isModifyReleaseJson, '1')
run: |
git checkout ${{ steps.release.outputs.target-tag-name }}
git show --name-only
shell: bash
- name: Install dependencies 👨🏻‍💻
uses: nick-fields/retry@v2
with:
timeout_seconds: 600
max_attempts: 2
shell: bash
retry_on: error
command: yarn
on_retry_command: rm -rf C:/Users/runneradmin/AppData/Local/node-gyp/
- name: Install UnPackaged 👨🏻‍💻
uses: nick-fields/retry@v2
with:
timeout_seconds: 600
max_attempts: 2
shell: bash
retry_on: error
command: yarn unpackaged
on_retry_command: rm -rf C:/Users/runneradmin/AppData/Local/node-gyp/
- name: Run electron-packager
run: |
if ${{ contains(needs.nightly_job.outputs.isModifyReleaseJson, '1') }} ; \
then if ${{ contains(steps.release.outputs.new-tag-name, 'nightly') }} ; \
then yarn node update-version.js --newTag ${{needs.nightly_job.outputs.tag-name}} --SHA7 ${{ steps.sha.outputs.sha7 }} --buildTime ${{ steps.vars.outputs.date }} ; \
else yarn node update-version.js --newTag ${{needs.nightly_job.outputs.tag-name}} --SHA7 ${{ steps.sha.outputs.sha7 }} --buildTime ${{ steps.vars.outputs.date }} --stable; \
fi
else yarn node update-version.js --buildTime ${{ steps.vars.outputs.date }} ; \
fi
yarn packager
shell: bash
# fix lxd dir error in ubuntu20.04
- name: fix lxd dir error
run: |
sudo ln -s /var/snap/lxd/common/lxd /var/lib/lxd
sudo snap install multipass --classic
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v1
with:
use_lxd: true
- name: Pack snap 📦
run: yarn make:snap:ci
- name: Generate shasum files
run: node build-scripts/common/shasum.js out/installers/${{ needs.nightly_job.outputs.tag-name }}
shell: bash
continue-on-error: true # Missing .sha files is still ok
- name: Release ${{ needs.nightly_job.outputs.file-name-lower }}-${{ needs.nightly_job.outputs.package-name }}-${{ steps.vars.outputs.system }} to GitHub 📰
uses: softprops/action-gh-release@v1
with:
prerelease: true
name: ${{ needs.nightly_job.outputs.file-name-lower }}-${{ needs.nightly_job.outputs.release-name }}
tag_name: ${{needs.nightly_job.outputs.tag-name}}
body: ${{ env.DESCRIBE }}
files: |
./out/installers/${{ needs.nightly_job.outputs.tag-name }}/**
# Generate snap token
# snapcraft export-login --snaps [SNAP_NAME] --channels edge -
- name: Upload snap to SnapCraft 📰
if: env.SNAPCRAFT_STORE_CREDENTIALS != ''
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
run: |
snapcraft upload --release=edge ./out/installers/${{ needs.nightly_job.outputs.tag-name }}/*.snap
appium_test_job:
needs: [nightly_job, release_snapcraft_job]
if: |
contains(github.event_name, 'schedule') || contains(needs.nightly_job.outputs.isRunAppium, '1')
timeout-minutes: 120
runs-on: ${{ matrix.os }}
strategy:
matrix:
test: [1, 2]
node-version: [16]
os: [windows-latest]
include:
- test: 1
os: windows-latest
- test: 2
os: windows-latest
environment:
name: CICD
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }}
GITHUB_PAT: ${{ secrets.PAT }}
EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
PHONE_NUMBER_ACCOUNT: ${{ secrets.PHONE_NUMBER_ACCOUNT }}
PHONE_NUMBER_TOKEN: ${{ secrets.PHONE_NUMBER_TOKEN }}
TEST1_EMAIL: ${{ secrets.TEST1_EMAIL }}
TEST2_EMAIL: ${{ secrets.TEST2_EMAIL }}
TEST3_EMAIL: ${{ secrets.TEST3_EMAIL }}
TEST_EMAIL_DOMAIN: ${{ secrets.TEST_EMAIL_DOMAIN }}
TEST1_PHONE_NUMBER: ${{ secrets.TEST1_PHONE_NUMBER }}
TEST2_PHONE_NUMBER: ${{ secrets.TEST2_PHONE_NUMBER }}
TEST3_PHONE_NUMBER: ${{ secrets.TEST3_PHONE_NUMBER }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
TEST_RESET_PASSWORD: ${{ secrets.TEST_RESET_PASSWORD }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
steps:
- name: appium_test_job Get short SHA 🔑
run: |
echo "sha7=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
echo "nightly_job"
echo "isRunAppium: ${{needs.nightly_job.outputs.isRunAppium}}"
echo "repository: ${{needs.nightly_job.outputs.repository}}"
shell: bash
- name: Checkout ⬇️
uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }} 📮
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
registry-url: "https://npm.pkg.github.com"
scope: "@zeeis"
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }}
- name: Get message
run: |
git fetch --prune --unshallow
shell: bash
- name: Install dependencies 👨🏻‍💻
uses: nick-fields/retry@v2
with:
timeout_seconds: 600
max_attempts: 2
shell: bash
retry_on: error
command: yarn
- name: Install ${{ needs.nightly_job.outputs.file-name-lower }}.7z
run: |
curl -L https://github.com/${{ needs.nightly_job.outputs.repository }}/releases/download/${{needs.nightly_job.outputs.tag-name}}/${{ needs.nightly_job.outputs.file-name-lower }}-${{needs.nightly_job.outputs.tag-name}}-windows.7z > appPackage.7z
7z x appPackage.7z
shell: bash
- name: Install winappdriver.msi
run: |
Set-DisplayResolution -Width 1920 -Height 1080 -Force
Invoke-WebRequest "https://github.com/microsoft/WinAppDriver/releases/download/v1.2.1/WindowsApplicationDriver_1.2.1.msi" -OutFIle "C:\WindowsApplicationDriver_1.2.1.msi"
Start-Process msiexec -ArgumentList "/quiet","/x","{087BBF93-D9E3-4D27-BDBE-9C702E0066FC}" -Verb runAs -Wait
Start-Process msiexec -ArgumentList "/quiet","/i","C:\WindowsApplicationDriver_1.2.1.msi" -Verb runAs -Wait
Start-Sleep -s 5
shell: powershell
- name: Run appium
run: |
$env:JEST_TEST = 'true'
Start-Process PowerShell -ArgumentList "yarn test:appium"
Start-Sleep -s 10
- name: E2E appium creditDownload test for 7z 🧪
if: matrix.test == '1'
uses: nick-fields/retry@v2
with:
timeout_seconds: 6000
max_attempts: 3
shell: bash
retry_on: error
command: |
taskkill //F //IM "${{ needs.nightly_job.outputs.display-name }}.exe" || (echo "app is ready")
sleep 10s
yarn test:release:creditsDownload
- name: E2E appium creditUpload test for 7z 🧪
if: matrix.test == '2'
uses: nick-fields/retry@v2
with:
timeout_seconds: 6000
max_attempts: 3
shell: bash
retry_on: error
command: |
taskkill //F //IM "${{ needs.nightly_job.outputs.display-name }}.exe" || (echo "app is ready")
sleep 10s
yarn test:release:creditsUpload
- name: Download msi and exe
run: |
curl -L https://github.com/${{ needs.nightly_job.outputs.repository }}/releases/download/${{needs.nightly_job.outputs.tag-name}}/${{ needs.nightly_job.outputs.file-name-lower }}-${{needs.nightly_job.outputs.tag-name}}.exe > C:/appPackage.exe
curl -L https://github.com/${{ needs.nightly_job.outputs.repository }}/releases/download/${{needs.nightly_job.outputs.tag-name}}/${{ needs.nightly_job.outputs.file-name-lower }}-${{needs.nightly_job.outputs.tag-name}}.msi > C:/appPackage.msi
shell: bash
- name: Install ${{ needs.nightly_job.outputs.file-name-lower }}.msi
run: |
Start-Process msiexec -ArgumentList "/quiet","/i","C:\appPackage.msi"
shell: powershell
- name: Install ${{ needs.nightly_job.outputs.file-name-lower }}.exe
run: |
Start-Process -FilePath "C:\appPackage.exe" -Verb runAs -ArgumentList '/s','/v"/qn"'
Start-Sleep -s 30
shell: powershell
- name: E2E appium test for msi 🧪
uses: nick-fields/retry@v2
with:
timeout_seconds: 1800
max_attempts: 2
shell: bash
retry_on: error
command: |
taskkill //F //IM "${{ needs.nightly_job.outputs.display-name }}.exe" || (echo "app is ready")
sleep 10s
export APP_TYPE=msi
yarn test:release
unset APP_TYPE
- name: E2E appium test for exe 🧪
uses: nick-fields/retry@v2
with:
timeout_seconds: 1800
max_attempts: 2
shell: bash
retry_on: error
command: |
taskkill //F //IM "${{ needs.nightly_job.outputs.display-name }}.exe" || (echo "app is ready")
sleep 10s
export APP_TYPE=exe
yarn test:release
unset APP_TYPE
- name: Upload Test Results 🗃
if: |
cancelled() || failure()
uses: actions/upload-artifact@v3
with:
name: "appium-test-${{ matrix.test }}-output"
path: test/output/**