2022-11-08 01:40:21 +00:00
|
|
|
---
|
|
|
|
name: package and draft GitHub release
|
|
|
|
# https://github.com/product-os/flowzone/tree/master/.github/actions
|
|
|
|
inputs:
|
|
|
|
json:
|
2023-06-28 11:26:16 +00:00
|
|
|
description: 'JSON stringified object containing all the inputs from the calling workflow'
|
2022-11-08 01:40:21 +00:00
|
|
|
required: true
|
|
|
|
secrets:
|
2023-06-28 11:26:16 +00:00
|
|
|
description: 'JSON stringified object containing all the secrets from the calling workflow'
|
2022-11-08 01:40:21 +00:00
|
|
|
required: true
|
2023-05-16 00:02:37 +00:00
|
|
|
variables:
|
2023-06-28 11:26:16 +00:00
|
|
|
description: 'JSON stringified object containing all the variables from the calling workflow'
|
2023-05-16 00:02:37 +00:00
|
|
|
required: true
|
2022-11-08 01:40:21 +00:00
|
|
|
|
|
|
|
# --- custom environment
|
|
|
|
XCODE_APP_LOADER_EMAIL:
|
|
|
|
type: string
|
2023-06-28 11:26:16 +00:00
|
|
|
default: 'accounts+apple@balena.io'
|
2022-11-08 01:40:21 +00:00
|
|
|
NODE_VERSION:
|
|
|
|
type: string
|
2024-01-17 11:43:14 +00:00
|
|
|
default: '20.x'
|
2022-11-08 01:40:21 +00:00
|
|
|
VERBOSE:
|
|
|
|
type: string
|
2023-06-28 11:26:16 +00:00
|
|
|
default: 'true'
|
2022-11-08 01:40:21 +00:00
|
|
|
|
|
|
|
runs:
|
|
|
|
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
|
2023-06-28 11:26:16 +00:00
|
|
|
using: 'composite'
|
2022-11-08 01:40:21 +00:00
|
|
|
steps:
|
|
|
|
- name: Download custom source artifact
|
2024-09-12 15:48:40 +00:00
|
|
|
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
2022-11-08 01:40:21 +00:00
|
|
|
with:
|
2023-05-16 00:02:37 +00:00
|
|
|
name: custom-${{ github.event.pull_request.head.sha || github.event.head_commit.id }}-${{ runner.os }}-${{ runner.arch }}
|
2022-11-08 01:40:21 +00:00
|
|
|
path: ${{ runner.temp }}
|
|
|
|
|
|
|
|
- name: Extract custom source artifact
|
|
|
|
shell: pwsh
|
|
|
|
working-directory: .
|
|
|
|
run: tar -xf ${{ runner.temp }}/custom.tgz
|
|
|
|
|
|
|
|
- name: Setup Node.js
|
2024-11-05 08:52:19 +00:00
|
|
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
|
2022-11-08 01:40:21 +00:00
|
|
|
with:
|
|
|
|
node-version: ${{ inputs.NODE_VERSION }}
|
|
|
|
cache: npm
|
|
|
|
|
2024-03-11 18:37:34 +00:00
|
|
|
- name: Set up Python 3.11
|
|
|
|
if: runner.os == 'macOS'
|
2024-06-21 18:48:07 +00:00
|
|
|
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
|
2024-03-11 18:37:34 +00:00
|
|
|
with:
|
|
|
|
python-version: "3.11"
|
|
|
|
|
2022-11-08 01:40:21 +00:00
|
|
|
- name: Install additional tools
|
|
|
|
if: runner.os == 'Windows'
|
2022-11-10 20:13:03 +00:00
|
|
|
shell: bash
|
2022-11-08 01:40:21 +00:00
|
|
|
run: |
|
|
|
|
choco install yq
|
|
|
|
|
|
|
|
- name: Install additional tools
|
|
|
|
if: runner.os == 'macOS'
|
2022-11-10 20:13:03 +00:00
|
|
|
shell: bash
|
2022-11-08 01:40:21 +00:00
|
|
|
run: |
|
|
|
|
brew install coreutils
|
|
|
|
|
|
|
|
# https://www.electron.build/code-signing.html
|
|
|
|
# https://github.com/Apple-Actions/import-codesign-certs
|
|
|
|
- name: Import Apple code signing certificate
|
|
|
|
if: runner.os == 'macOS'
|
2024-12-17 11:53:05 +00:00
|
|
|
uses: apple-actions/import-codesign-certs@63fff01cd422d4b7b855d40ca1e9d34d2de9427d # v3
|
2022-11-08 01:40:21 +00:00
|
|
|
with:
|
|
|
|
p12-file-base64: ${{ fromJSON(inputs.secrets).APPLE_SIGNING }}
|
|
|
|
p12-password: ${{ fromJSON(inputs.secrets).APPLE_SIGNING_PASSWORD }}
|
|
|
|
|
|
|
|
- name: Import Windows code signing certificate
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
shell: powershell
|
|
|
|
run: |
|
2024-03-06 11:06:27 +00:00
|
|
|
Set-Content -Path ${{ runner.temp }}/certificate.base64 -Value $env:SM_CLIENT_CERT_FILE_B64
|
|
|
|
certutil -decode ${{ runner.temp }}/certificate.base64 ${{ runner.temp }}/Certificate_pkcs12.p12
|
2022-11-08 01:40:21 +00:00
|
|
|
Remove-Item -path ${{ runner.temp }} -include certificate.base64
|
|
|
|
env:
|
2024-03-06 11:06:27 +00:00
|
|
|
SM_CLIENT_CERT_FILE_B64: ${{ fromJSON(inputs.secrets).SM_CLIENT_CERT_FILE_B64 }}
|
2022-11-08 01:40:21 +00:00
|
|
|
|
|
|
|
# https://github.com/product-os/scripts/tree/master/shared
|
|
|
|
# https://github.com/product-os/balena-concourse/blob/master/pipelines/github-events/template.yml
|
|
|
|
- name: Package release
|
2022-11-10 20:13:03 +00:00
|
|
|
shell: bash
|
2022-11-08 01:40:21 +00:00
|
|
|
run: |
|
|
|
|
set -ea
|
|
|
|
|
|
|
|
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
|
|
|
|
|
|
|
|
runner_os="$(echo "${RUNNER_OS}" | tr '[:upper:]' '[:lower:]')"
|
|
|
|
runner_arch="$(echo "${RUNNER_ARCH}" | tr '[:upper:]' '[:lower:]')"
|
|
|
|
|
|
|
|
if [[ $runner_os =~ darwin|macos|osx ]]; then
|
|
|
|
CSC_KEY_PASSWORD=${{ fromJSON(inputs.secrets).APPLE_SIGNING_PASSWORD }}
|
|
|
|
CSC_KEYCHAIN=signing_temp
|
|
|
|
CSC_LINK=${{ fromJSON(inputs.secrets).APPLE_SIGNING }}
|
|
|
|
|
|
|
|
elif [[ $runner_os =~ windows|win ]]; then
|
2024-03-06 11:06:27 +00:00
|
|
|
SM_HOST=${{ fromJSON(inputs.secrets).SM_HOST }}
|
|
|
|
SM_API_KEY=${{ fromJSON(inputs.secrets).SM_API_KEY }}
|
|
|
|
SM_CLIENT_CERT_FILE='${{ runner.temp }}\Certificate_pkcs12.p12'
|
|
|
|
SM_CLIENT_CERT_PASSWORD=${{ fromJSON(inputs.secrets).SM_CLIENT_CERT_PASSWORD }}
|
|
|
|
SM_CODE_SIGNING_CERT_SHA1_HASH=${{ fromJSON(inputs.secrets).SM_CODE_SIGNING_CERT_SHA1_HASH }}
|
|
|
|
|
|
|
|
curl --silent --retry 3 --fail https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download \
|
|
|
|
-H "x-api-key:$SM_API_KEY" \
|
|
|
|
-o smtools-windows-x64.msi
|
|
|
|
msiexec -i smtools-windows-x64.msi -qn
|
|
|
|
PATH="/c/Program Files/DigiCert/DigiCert One Signing Manager Tools:${PATH}"
|
|
|
|
smksp_registrar.exe list
|
|
|
|
smctl.exe keypair ls
|
|
|
|
/c/Windows/System32/certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
|
|
|
|
smksp_cert_sync.exe
|
2022-11-08 01:40:21 +00:00
|
|
|
|
|
|
|
# (signtool.exe) https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md#installed-windows-sdks
|
|
|
|
PATH="/c/Program Files (x86)/Windows Kits/10/bin/${runner_arch}:${PATH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
npm run package
|
|
|
|
|
|
|
|
find dist -type f -maxdepth 1
|
|
|
|
|
|
|
|
env:
|
|
|
|
# https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks
|
|
|
|
# https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks#about-workflow-runs-from-public-forks
|
|
|
|
CSC_FOR_PULL_REQUEST: true
|
2024-03-06 11:06:27 +00:00
|
|
|
# https://docs.digicert.com/es/software-trust-manager/ci-cd-integrations/plugins/github-custom-action-for-keypair-signing.html
|
|
|
|
TIMESTAMP_SERVER: http://timestamp.digicert.com
|
2022-11-08 01:40:21 +00:00
|
|
|
# Apple notarization (automation/build-bin.ts)
|
|
|
|
XCODE_APP_LOADER_EMAIL: ${{ inputs.XCODE_APP_LOADER_EMAIL }}
|
|
|
|
XCODE_APP_LOADER_PASSWORD: ${{ fromJSON(inputs.secrets).XCODE_APP_LOADER_PASSWORD }}
|
2023-06-29 11:41:07 +00:00
|
|
|
XCODE_APP_LOADER_TEAM_ID: ${{ inputs.XCODE_APP_LOADER_TEAM_ID }}
|
2022-11-08 01:40:21 +00:00
|
|
|
|
2022-11-17 23:06:37 +00:00
|
|
|
- name: Upload artifacts
|
2024-11-05 09:50:56 +00:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
|
2022-11-08 01:40:21 +00:00
|
|
|
with:
|
2023-12-19 17:26:28 +00:00
|
|
|
name: gh-release-${{ github.event.pull_request.head.sha || github.event.head_commit.id }}-${{ strategy.job-index }}
|
2022-11-17 23:06:37 +00:00
|
|
|
path: dist
|
2022-11-08 01:40:21 +00:00
|
|
|
retention-days: 1
|
2023-12-19 17:26:28 +00:00
|
|
|
if-no-files-found: error
|