Skip to content

Commit

Permalink
Merge pull request #26 from Chia-Network/add-build-process
Browse files Browse the repository at this point in the history
Add build process
  • Loading branch information
MichaelTaylor3D authored Nov 11, 2022
2 parents 2d873a5 + 6c974bf commit dd9a02f
Show file tree
Hide file tree
Showing 13 changed files with 796 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Compares the version in package.json to tags on the repo. If the tag doesn't exist, a new tag is created, which
# then triggers the normal "on tag" release automation in the build job
name: Auto Tag

on:
push:
branches:
- main

concurrency:
group: main-release-check

jobs:
check-version:
name: Check version increment
runs-on: ubuntu-latest
steps:
- uses: Chia-Network/actions/clean-workspace@main

- name: Checkout current branch
uses: actions/checkout@v3
with:
# Need PACKAGE_ADMIN_PAT token so when the tag is created, the tag automation runs
token: ${{ secrets.PACKAGE_ADMIN_PAT }}
fetch-depth: 0

- name: Check for current version tag. Create if it doesn't exist
run: |
version=$(cat $GITHUB_WORKSPACE/package.json | jq -r '.version')
echo "Version is: $version"
if [ $(git tag -l "$version") ]; then
echo "Tag exists, nothing to do"
else
echo "Tag does not exist. Creating and pushing tag"
rm -f CHANGELOG.md
npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0
git add CHANGELOG.md
git config --global user.name 'ChiaAutomation'
git config --global user.email '[email protected]'
git commit -m "Updating changelog for $version"
git tag $version
git push origin $version
git push origin main
fi
200 changes: 200 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: Build Binaries

on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
build:
name: Build Binaries
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
include:
- runs-on: ubuntu-latest
artifact-name: linux-x64
build-command: npm run create-linux-x64-dist
- runs-on: macos-latest
artifact-name: macos-x64
build-command: npm run create-mac-x64-dist
- runs-on: windows-2019
artifact-name: windows-x64
build-command: npm run create-win-x64-dist

steps:
- uses: Chia-Network/actions/clean-workspace@main

- name: Checkout Code
uses: actions/checkout@v2

- name: Setup Node 16.x
uses: actions/[email protected]
with:
node-version: '16.0.0'

- name: Ignore Husky
run: npm set-script prepare ""
if: matrix.runs-on != 'windows-2019'

- name: npm install
run: |
node --version
npm install
- name: npm cache clear --force
run: npm cache clear --force

- name: npm cache rm
run: npm cache rm --force

- name: npm cache verify
run: npm cache verify

- name: install global packages
run: npm i -g @babel/cli @babel/preset-env pkg

- name: create distributions
run: ${{ matrix.build-command }}

- name: Make executable
run: chmod +x dist/climate-portal

### If using sqlite, uncomment the following 2 sections ###
### and add a line to sign the sqlite binaries in the ###
### Mac section. ###

# - name: Copy sqlite3 (non windows)
# run: cp ./node_modules/sqlite3/build/Release/node_sqlite3.node ./dist/
# if: matrix.runs-on != 'windows-2019'

# - name: Copy sqlite3 (windows)
# run: cp .\node_modules\sqlite3\build\Release\node_sqlite3.node .\dist\
# if: matrix.runs-on == 'windows-2019'

# Windows Code Signing
- name: Decode code signing cert into an encrypted file
if: matrix.runs-on == 'windows-2019'
uses: kitek/[email protected]
with:
encoded-value: ${{ secrets.WIN_CODE_SIGN_CERT }}
destination-file: .\win_code_sign_cert.pfx

- name: Sign windows artifacts
if: matrix.runs-on == 'windows-2019'
uses: chia-network/actions/sign/windows@main
with:
certificate_path: .\win_code_sign_cert.pfx
certificate_password: ${{ secrets.WIN_CODE_SIGN_PASSWORD }}
file: ${{ github.workspace }}/dist/climate-portal.exe

# Mac .pkg build + sign
- name: Import Apple installer signing certificate
#if: steps.check_secrets.outputs.HAS_SECRET
if: matrix.runs-on == 'macos-latest'
uses: Apple-Actions/import-codesign-certs@v1
with:
keychain-password: ${{ secrets.KEYCHAIN_PASSWORD }}
p12-file-base64: ${{ secrets.APPLE_DEV_ID_INSTALLER }}
p12-password: ${{ secrets.APPLE_DEV_ID_INSTALLER_PASS }}

- name: Import Apple Application signing certificate
#if: steps.check_secrets.outputs.HAS_SECRET
if: matrix.runs-on == 'macos-latest'
uses: Apple-Actions/import-codesign-certs@v1
with:
create-keychain: false # Created when importing the first cert
keychain-password: ${{ secrets.KEYCHAIN_PASSWORD }}
p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }}
p12-password: ${{ secrets.APPLE_DEV_ID_APP_PASS }}

- name: Build Mac .pkg
if: matrix.runs-on == 'macos-latest'
run: |
rm -rf ${{ github.workspace }}/build-scripts/macos/darwin/application || true
cp -r ${{ github.workspace }}/dist ${{ github.workspace }}/build-scripts/macos/application
echo "Signing the binaries"
codesign -f -s "Developer ID Application: Chia Network Inc." --timestamp --options=runtime --entitlements ${{ github.workspace }}/build-scripts/macos/entitlements.mac.plist ${{ github.workspace }}/build-scripts/macos/application/climate-portal
# Makes the .pkg in ./build-scripts/macos/target/pkg
echo "Building the .pkg"
bash ${{ github.workspace }}/build-scripts/macos/build-macos.sh ClimatePortal
mkdir -p ${{ github.workspace }}/build-scripts/macos/target/pkg-signed
echo "Signing the .pkg"
productsign --sign "Developer ID Installer: Chia Network Inc." ${{ github.workspace }}/build-scripts/macos/target/pkg/ClimatePortal-macos-installer-x64.pkg ${{ github.workspace }}/build-scripts/macos/target/pkg-signed/ClimatePortal-macos-installer-x64.pkg
echo "Notarizing the .pkg"
npm install -g notarize-cli
notarize-cli \
--file=${{ github.workspace }}/build-scripts/macos/target/pkg-signed/ClimatePortal-macos-installer-x64.pkg \
--bundle-id net.chia.climate-portal \
--username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \
--password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}"
- name: Upload Mac Installer
if: matrix.runs-on == 'macos-latest'
uses: actions/upload-artifact@v2
with:
name: mac-installer
path: ${{ github.workspace }}/build-scripts/macos/target/pkg-signed

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifact-name }}
path: ${{ github.workspace }}/dist

release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
steps:
- name: Download Windows artifacts
uses: actions/download-artifact@v2
with:
name: windows-x64
path: windows-x64

- name: Download MacOS artifacts
uses: actions/download-artifact@v2
with:
name: mac-installer
path: mac-installer

- name: Download Linux artifacts
uses: actions/download-artifact@v2
with:
name: linux-x64
path: linux-x64

- name: Get tag name
id: tag-name
run: |
echo ::set-output name=TAGNAME::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Create zips
run: |
zip -r windows-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip windows-x64
zip -r macos-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip mac-installer
zip -r linux-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip linux-x64
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
windows-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip
macos-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip
linux-x64-${{ steps.tag-name.outputs.TAGNAME }}.zip
42 changes: 42 additions & 0 deletions .github/workflows/ensure-version-increment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow runs on any PRs that are targeting main, and ensures that the version in package.json is incremented
name: Check Version Increment

on:
pull_request:
branches:
- 'main'

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
cancel-in-progress: true

jobs:
check-version:
name: Check version increment
runs-on: ubuntu-latest
steps:
- uses: Chia-Network/actions/clean-workspace@main

- name: Checkout current branch
uses: actions/checkout@v2
with:
path: branch-repo

- name: Checkout main
uses: actions/checkout@v2
with:
ref: main
path: main-repo

- name: Check Versions
run: |
main_version=$(cat $GITHUB_WORKSPACE/main-repo/package.json | jq -r '.version')
branch_version=$(cat $GITHUB_WORKSPACE/branch-repo/package.json | jq -r '.version')
echo "Main version: $main_version"
echo "Branch version: $branch_version"
if [[ "$branch_version" == "$main_version" ]]; then
echo "Version in package.json on this branch is not changing. Version must incremenet for a merge to main"
exit 1
fi
Loading

0 comments on commit dd9a02f

Please sign in to comment.