Skip to content

Commit 3bfc2a2

Browse files
Artem Panfilovabrodkin
authored andcommitted
CI: add manual release build
Signed-off-by: Artem Panfilov <[email protected]>
1 parent 9ff39eb commit 3bfc2a2

File tree

5 files changed

+260
-72
lines changed

5 files changed

+260
-72
lines changed

.github/scripts/create-release.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import os
5+
import sys
6+
from datetime import date
7+
8+
import ghapi
9+
from ghapi.actions import github_token
10+
11+
12+
def parse_arguments():
13+
parser = argparse.ArgumentParser()
14+
parser.add_argument('--owner', required=True)
15+
parser.add_argument('--path', required=True)
16+
parser.add_argument('--tag', required=True)
17+
18+
return parser.parse_args()
19+
20+
21+
def main():
22+
args = parse_arguments()
23+
tag = args.tag
24+
25+
try:
26+
api = ghapi.core.GhApi(owner=args.owner,
27+
repo='arc-gnu-toolchain',
28+
token=github_token())
29+
30+
31+
rel = api.create_release(tag_name=tag,
32+
name=f'GNU Toolchain for ARC Processors, {tag}',
33+
body='**Automated Release**\n'
34+
f'{tag}-release',
35+
prerelease=True)
36+
37+
for dirs, _, files in os.walk(args.path):
38+
for file in files:
39+
asset = os.path.join(dirs, file)
40+
api.upload_file(rel, asset)
41+
42+
except Exception as ex:
43+
sys.exit(ex)
44+
45+
46+
if __name__ == "__main__":
47+
main()
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
targets:
7+
description: Stringified JSON target list
8+
required: false
9+
default: >-
10+
["arc", "arc32", "arc64"]
11+
type: string
12+
13+
gcc_branch:
14+
description: GCC branch name
15+
required: false
16+
default: arc64
17+
type: string
18+
19+
binutils_branch:
20+
description: Binutils branch name
21+
required: false
22+
default: arc64
23+
type: string
24+
25+
newlib_branch:
26+
description: Newlib branch name
27+
required: false
28+
default: arc64
29+
type: string
30+
31+
glibc_branch:
32+
description: glibc branch name
33+
required: false
34+
default: arc64
35+
type: string
36+
37+
release_tag:
38+
description: Release tag
39+
required: false
40+
default: "2022.03"
41+
type: string
42+
43+
jobs:
44+
toolchains:
45+
uses: ./.github/workflows/build-toolchains.yml
46+
with:
47+
targets: ${{ github.event.inputs.targets }}
48+
gcc_branch: ${{ github.event.inputs.gcc_branch }}
49+
binutils_branch: ${{ github.event.inputs.binutils_branch }}
50+
newlib_branch: ${{ github.event.inputs.newlib_branch }}
51+
glibc_branch: ${{ github.event.inputs.glibc_branch }}
52+
release_tag: ${{ github.event.inputs.release_tag }}
53+
54+
create-release:
55+
needs: toolchains
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout sources
59+
uses: actions/checkout@v2
60+
61+
- name: Install pip3 dependencies
62+
run: |
63+
pip3 install ghapi
64+
65+
- name: Download artifacts
66+
uses: actions/download-artifact@v3
67+
with:
68+
path: ${{ github.workspace }}/output
69+
70+
- name: Create release
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
${{ github.workspace }}/.github/scripts/create-release.py \
75+
--owner ${{ github.repository_owner }} \
76+
--tag ${{ github.event.inputs.release_tag }} \
77+
--path ${{ github.workspace }}/output
78+
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Build Toolchains
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
targets:
7+
description: Stringified JSON target list
8+
required: false
9+
default: >-
10+
["arc32", "arc64"]
11+
type: string
12+
13+
gcc_branch:
14+
description: GCC branch name
15+
required: false
16+
default: arc64
17+
type: string
18+
19+
binutils_branch:
20+
description: Binutils branch name
21+
required: false
22+
default: arc64
23+
type: string
24+
25+
newlib_branch:
26+
description: Newlib branch name
27+
required: false
28+
default: arc64
29+
type: string
30+
31+
glibc_branch:
32+
description: glibc branch name
33+
required: false
34+
default: arc64
35+
type: string
36+
37+
release_tag:
38+
description: release tag
39+
required: false
40+
default: ""
41+
type: string
42+
43+
env:
44+
build_dir: ${{ github.workspace }}/output
45+
46+
jobs:
47+
build:
48+
runs-on: ubuntu-18.04
49+
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
mode: [newlib, linux]
54+
target: ${{ fromJSON(inputs.targets) }}
55+
56+
# exclude arc32 bare-metal toolchain because it is built by arc64 multilib toolchain
57+
exclude:
58+
- { mode: newlib, target: arc32 }
59+
60+
steps:
61+
- uses: actions/checkout@v2
62+
- name: Install apt dependencies
63+
run: |
64+
sudo apt-get -y update
65+
sudo apt-get install -y --no-install-recommends \
66+
autoconf \
67+
automake \
68+
autotools-dev \
69+
bc \
70+
bison \
71+
build-essential \
72+
curl \
73+
flex \
74+
gawk \
75+
gperf \
76+
libgmp-dev \
77+
libmpc-dev \
78+
libmpfr-dev \
79+
libtool \
80+
patchutils \
81+
texinfo
82+
83+
- name: Build ${{ matrix.target }}-${{ matrix.mode }} toolchain
84+
id: build_toolchain
85+
86+
run: |
87+
if [ "${{ matrix.mode }}" == "linux" ]; then
88+
BUILD_FLAGS="--enable-linux"
89+
MODE="glibc";
90+
else
91+
BUILD_FLAGS="--enable-multilib"
92+
MODE="elf";
93+
fi
94+
95+
if [ -n ${{ inputs.release_tag }} ]; then
96+
RELEASE_TAG="${{ inputs.release_tag }}"
97+
else
98+
RELEASE_TAG="$(date --utc '+%Y.%m.%d')"
99+
fi
100+
101+
echo ::set-output name=toolchain_name::${{ matrix.target }}-${MODE}-${RELEASE_TAG}
102+
103+
${{ github.workspace }}/configure \
104+
${BUILD_FLAGS} \
105+
--target=${{ matrix.target }} \
106+
--prefix=${{ env.build_dir }} \
107+
--disable-qemu \
108+
--disable-werror
109+
110+
cat > build.config <<EOF
111+
GCC_BRANCH=${{ inputs.gcc_branch }}
112+
BINUTILS_BRANCH=${{ inputs.binutils_branch }}
113+
NEWLIB_BRANCH=${{ inputs.newlib_branch }}
114+
GLIBC_BRANCH=${{ inputs.glibc_branch }}
115+
EOF
116+
117+
make ${{ matrix.mode }} -j$(nproc)
118+
shell: bash
119+
120+
- name: Create toolchain tarball
121+
run: |
122+
tar -czvf ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz --owner=0 --group=0 -C ${{ env.build_dir }} .
123+
124+
- name: Upload toolchain tarball
125+
uses: actions/upload-artifact@v3
126+
with:
127+
name: ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz
128+
path: ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz
129+
retention-days: 7

.github/workflows/ci.yml

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,14 @@
11
name: CI
22

33
on:
4+
repository_dispatch:
45
push:
56
branches: [master]
67
pull_request:
78
branches: [master]
89
schedule:
9-
- cron: "0 0 * * *"
10-
workflow_dispatch:
11-
repository_dispatch:
12-
13-
env:
14-
build_dir: ${{ github.workspace }}/output
10+
- cron: "0 0 * * 1-5"
1511

1612
jobs:
17-
build:
18-
name: Building ${{ matrix.target }}-${{ matrix.mode }} toolchain
19-
runs-on: ubuntu-18.04
20-
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
mode: [newlib, linux]
25-
target: [arc32, arc64]
26-
27-
exclude:
28-
- { mode: newlib, target: arc32 }
29-
30-
steps:
31-
- uses: actions/checkout@v2
32-
- name: Install apt dependencies
33-
run: |
34-
sudo apt-get -y update
35-
sudo apt-get install -y --no-install-recommends \
36-
autoconf \
37-
automake \
38-
autotools-dev \
39-
bc \
40-
bison \
41-
build-essential \
42-
curl \
43-
flex \
44-
gawk \
45-
gperf \
46-
libgmp-dev \
47-
libmpc-dev \
48-
libmpfr-dev \
49-
libtool \
50-
patchutils \
51-
texinfo
52-
53-
- name: Build ${{ matrix.target }}-${{ matrix.mode }} toolchain
54-
id: build_toolchain
55-
run: |
56-
echo ::set-output name=toolchain_name::${{ matrix.target }}-${{ matrix.mode }}-nightly-$(date --utc '+%Y.%m.%d')
57-
58-
if [ "${{ matrix.mode }}" == "linux" ]; then
59-
BUILD_FLAGS="--enable-linux"
60-
else
61-
BUILD_FLAGS="--enable-multilib"
62-
fi
63-
64-
${{ github.workspace }}/configure \
65-
${BUILD_FLAGS} \
66-
--target=${{ matrix.target }} \
67-
--prefix=${{ env.build_dir }} \
68-
--disable-qemu \
69-
--disable-werror
70-
71-
make ${{ matrix.mode }} -j$(nproc)
72-
73-
- name: Create toolchain archive
74-
run: |
75-
tar -czvf ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz --owner=0 --group=0 -C ${{ env.build_dir }} .
76-
77-
- name: Upload artifacts
78-
uses: actions/upload-artifact@v2
79-
with:
80-
name: ${{ steps.build_toolchain.outputs.toolchain_name }}
81-
path: ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz
82-
retention-days: 7
13+
toolchains:
14+
uses: ./.github/workflows/build-toolchains.yml

Makefile.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ GLIBC_BRANCH := arc64
1919
BUILDROOT_BRANCH := arc64
2020
LINUX_BRANCH := arc64
2121

22+
-include build.config
23+
2224
BINUTILS_SRCDIR := $(srcdir)/binutils-gdb
2325
NEWLIB_SRCDIR := $(srcdir)/newlib
2426
GCC_SRCDIR := $(srcdir)/gcc

0 commit comments

Comments
 (0)