build: switch to GitHub Actions (#36)

* build: switch to GitHub Actions

* fix: only upload on push to main
This commit is contained in:
Shelley Vohr 2024-08-16 10:10:48 +02:00 коммит произвёл GitHub
Родитель d3ebb27bf0
Коммит c2b0d953c7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 99 добавлений и 143 удалений

Просмотреть файл

@ -1,93 +0,0 @@
version: 2.1
orbs:
azure-cli: circleci/azure-cli@1.2.2
commands:
prepare:
steps:
- checkout
- run:
name: Install Packages
command: sudo apt update && sudo apt install -y binutils-arm-linux-gnueabi binutils-arm-linux-gnueabihf binutils-mips64el-linux-gnuabi64 binutils-mipsel-linux-gnu
- run:
name: Delete Unneeded Freetype Packages
command: |
if [ -d out/sysroot-build/bullseye/debian-packages]; then
rm out/sysroot-build/bullseye/debian-packages/libfreetype6*
fi
- run:
name: Install dependencies
command: python3 -m pip install --upgrade requests
build-image:
parameters:
image:
type: string
steps:
- prepare
- run:
name: Build << parameters.image >> sysroot
command: |
./build/linux/sysroot_scripts/sysroot_creator.py build << parameters.image >>
- persist_to_workspace:
root: .
paths:
- out/sysroot-build/bullseye/*.tar.xz
jobs:
build:
parameters:
image:
type: string
docker:
- image: cimg/python:3.9.19
resource_class: 2xlarge
steps:
- build-image:
image: << parameters.image >>
upload-images:
docker:
- image: cimg/python:3.9.19
resource_class: large
steps:
- prepare
- azure-cli/install
- attach_workspace:
at: .
- run:
name: Upload Sysroots
command: SKIP_SYSROOT_BUILD=true ./build/linux/sysroot_scripts/build_and_upload.py
- store_artifacts:
path: build/linux/sysroot_scripts/sysroots.json
destination: sysroots.json
workflows:
version: 2.1
build-and-upload:
jobs:
- build:
image: amd64
name: build-image-amd64
- build:
image: i386
name: build-image-i386
- build:
image: armhf
name: build-image-armhf
- build:
image: arm64
name: build-image-arm64
- build:
image: mipsel
name: build-image-mipsel
- build:
image: mips64el
name: build-image-mips64el
- upload-images:
requires:
- build-image-amd64
- build-image-i386
- build-image-armhf
- build-image-arm64
- build-image-mipsel
- build-image-mips64el

70
.github/workflows/build.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,70 @@
name: "Build and Upload Sysroots"
on:
pull_request:
types:
- opened
- synchronize
push:
branches:
- main
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
strategy:
matrix:
arch: [amd64, i386, armhf, arm64, mipsel, mips64el]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
- name: Install Packages
run: |
sudo apt update
sudo apt install -y binutils-arm-linux-gnueabi binutils-arm-linux-gnueabihf binutils-mips64el-linux-gnuabi64 binutils-mipsel-linux-gnu
- name: Install dependencies
run: python3 -m pip install --upgrade requests
- name: Build Sysroot
run: ./build/linux/sysroot_scripts/sysroot_creator.py build ${{ matrix.arch }}
- name: Upload Sysroot Artifact
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # 4.2.6
with:
name: debian_bullseye_${{ matrix.arch }}_sysroot.tar.xz
path: out/sysroot-build/bullseye/debian_bullseye_${{ matrix.arch }}_sysroot.tar.xz
upload:
name: Upload Sysroots to Azure
runs-on: ubuntu-latest
needs: build
env:
AZURE_STORAGE_SAS_TOKEN: ${{ secrets.AZURE_STORAGE_SAS_TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
- name: Install dependencies
run: python3 -m pip install --upgrade requests
- name: Download Sysroot Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
with:
path: out/sysroot-build/bullseye
merge-multiple: true
- name: Download sysroots.json from Electron
run: |
json_url="https://github.com/electron/electron/blob/main/script/sysroots.json"
curl --output build/linux/sysroot_scripts/sysroots.json $json_url
az extension add --name storage-preview
- name: Upload Sysroots to Azure
if: github.event_name == 'push'
run: ./build/linux/sysroot_scripts/build_and_upload.py --upload
- name: Upload Sysroot JSON Artifact
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # 4.2.6
with:
name: sysroots.json
path: build/linux/sysroot_scripts/sysroots.json

Просмотреть файл

@ -6,6 +6,7 @@
"""Automates running sysroot-creator.sh for each supported arch.
"""
import argparse
import json
import multiprocessing
import os
@ -15,13 +16,20 @@ import sysroot_creator
DEFAULT_URL_PREFIX = "https://dev-cdn.electronjs.org/linux-sysroots"
class Action:
BUILD = 1 << 0
UPLOAD = 1 << 1
BUILD_AND_UPLOAD = BUILD | UPLOAD
def build_and_upload(key, arch, lock):
def build_and_upload(key, arch, lock, action):
script_dir = os.path.dirname(os.path.realpath(__file__))
if "SKIP_SYSROOT_BUILD" not in os.environ:
if action & Action.BUILD:
sysroot_creator.build_sysroot(arch)
if "AZURE_STORAGE_SAS_TOKEN" in os.environ:
if action & Action.UPLOAD:
if "AZURE_STORAGE_SAS_TOKEN" not in os.environ:
raise RuntimeError("AZURE_STORAGE_SAS_TOKEN is required to upload sysroots")
sysroot_creator.upload_sysroot(arch)
tarball = "%s_%s_%s_sysroot.tar.xz" % (
@ -67,7 +75,7 @@ def build_and_upload(key, arch, lock):
f.write("\n")
def main():
def main(action):
key = "%s-%s" % (sysroot_creator.ARCHIVE_TIMESTAMP,
sysroot_creator.SYSROOT_RELEASE)
@ -76,7 +84,7 @@ def main():
for arch in sysroot_creator.TRIPLES:
proc = multiprocessing.Process(
target=build_and_upload,
args=(key, arch, lock),
args=(key, arch, lock, action),
)
procs.append((
"%s %s (%s)" %
@ -98,4 +106,19 @@ def main():
if __name__ == "__main__":
sys.exit(main())
parser = argparse.ArgumentParser(description='Build and upload sysroots')
parser.add_argument('--build',
action='store_true',
help='Skip building sysroots')
parser.add_argument('--upload',
action='store_true',
help='Upload sysroots')
args = parser.parse_args()
action = Action.BUILD_AND_UPLOAD
if args.build:
action &= ~Action.UPLOAD
if args.upload:
action &= ~Action.BUILD
sys.exit(main(action))

Просмотреть файл

@ -1,44 +0,0 @@
{
"bullseye_amd64": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "568accebf3fda896469cdba535390559ab3b5b4218a569a7b63e1201b2c749e2",
"SysrootDir": "debian_bullseye_amd64-sysroot",
"Tarball": "debian_bullseye_amd64_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_arm64": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "e5a0861af612e6ffc3055e72be6e5d91e9b12b2c4d93590a88064a00093f0fb0",
"SysrootDir": "debian_bullseye_arm64-sysroot",
"Tarball": "debian_bullseye_arm64_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_armhf": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "31d3f7a7f5a12c515e42fe580c00a1db0b736687e639b08a7446255662ef131a",
"SysrootDir": "debian_bullseye_armhf-sysroot",
"Tarball": "debian_bullseye_armhf_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_i386": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "892c196f1c290e585c13772773baec7030d871fecccd899bf105cc6061dadb93",
"SysrootDir": "debian_bullseye_i386-sysroot",
"Tarball": "debian_bullseye_i386_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_mips64el": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "2b749935b7dd2eb141978910577e109339487dc80a1eb27d05cbf6218225f7fb",
"SysrootDir": "debian_bullseye_mips64el-sysroot",
"Tarball": "debian_bullseye_mips64el_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
},
"bullseye_mipsel": {
"Key": "20230611T210420Z-2",
"Sha256Sum": "65ba5bfb816826b25049cf5254119abbb4a26fb7a7ffe1061fe8f50e749101fd",
"SysrootDir": "debian_bullseye_mipsel-sysroot",
"Tarball": "debian_bullseye_mipsel_sysroot.tar.xz",
"URL": "https://dev-cdn.electronjs.org/linux-sysroots"
}
}