Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: switch to GitHub Actions #36

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions .circleci/config.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Build and Upload Sysroots"

on:
pull_request:
types:
- opened
- synchronize
codebytere marked this conversation as resolved.
Show resolved Hide resolved
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
MarshallOfSound marked this conversation as resolved.
Show resolved Hide resolved
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
35 changes: 29 additions & 6 deletions build/linux/sysroot_scripts/build_and_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""Automates running sysroot-creator.sh for each supported arch.
"""

import argparse
import json
import multiprocessing
import os
Expand All @@ -15,13 +16,20 @@

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" % (
Expand Down Expand Up @@ -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)

Expand All @@ -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)" %
Expand All @@ -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))
44 changes: 0 additions & 44 deletions build/linux/sysroot_scripts/sysroots.json

This file was deleted.

Loading