-
Notifications
You must be signed in to change notification settings - Fork 39
executable file
·169 lines (155 loc) · 5.24 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
on:
release:
types: [released]
env:
REGISTRY: ghcr.io
NAMESPACE: kendryte
IMAGE_NAME: k230_sdk
jobs:
build_docker:
name: Build-Docker
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
-
name: Build docker and test
run: |
docker build -f tools/docker/Dockerfile -t ${{ env.IMAGE_NAME }} tools/docker --label "runnumber=${GITHUB_RUN_ID}"
docker run --rm ${{ env.IMAGE_NAME }}
-
name: release docker image
run: |
IMAGE_ID=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
#[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
# [ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo "start to tag docker image with ver $VERSION"
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
echo "start to tag docker image with latest tag"
docker tag $IMAGE_NAME $IMAGE_ID:latest
echo "start to push docker image with ver $VERSION"
docker push $IMAGE_ID:$VERSION
echo "start to push docker image with latest tag"
docker push $IMAGE_ID:latest
echo "finished to push docker image"
build_image:
name: Build-Image
needs: build_docker
runs-on: [ubuntu-latest]
timeout-minutes: 180
container:
image: ghcr.io/kendryte/k230_sdk:latest
env:
CONF: k230_${{ matrix.cfg }}_defconfig
options: --hostname release --user root
strategy:
matrix:
cfg: ["canmv", "evb"]
steps:
- name: Check for dockerenv
run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)
- name: Install Nvm/Node for Actions Checkout Env
run: |
pwd
ls -alht
export NVM_DIR="$HOME/.nvm" && (
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"
nvm install node || exit 1
node --version || exit 1
- name: Checkout Source Code
uses: actions/checkout@v4
with:
fetch-depth: 0
clean: true
submodules: recursive
- name: Download Toolchain and Setup Build Env
run: |
hostname
uname -a
whoami
pwd
git config --global --add safe.directory $PWD
git config --global --list
ls -alht
echo "download toolchain and build env"
make prepare_sourcecode || exit 1
ls -alht
mkdir -p /opt/ || exit 1
rm -rf /opt/toolchain/
echo "show toolchain"
ls -alht $PWD/toolchain/ || exit 1
echo "link ./toolchain to /opt/toolchain"
ln -s $PWD/toolchain /opt/ || exit 1
echo "show /opt/toolchain/"
ls -alht /opt/toolchain/ || exit 1
ls -alht /opt/toolchain/Xuantie-900-gcc-linux* || exit 1
ls -alht /opt/toolchain/riscv64-linux* || exit 1
- name: Build image
run: |
pwd
ls -alht
echo "start to build k230 images"
make CONF=$CONF || exit 1
echo "---show output---"
ls -alht output/${CONF}/images || exit 1
pwd
- name: Show Output Directory For Debug Purpose
run: |
pwd
ls -alht
ls -alht output/${CONF}/images/
# Copy compiled files to /github/workspace/artifacts
mkdir -p /github/workspace/artifacts
cp output/${CONF}/images/k230_${{ matrix.cfg }}* /github/workspace/artifacts/
ls -alht /github/workspace/artifacts/
shell: bash
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.cfg }}
path: /github/workspace/artifacts
upload_release:
needs: build_image
name: Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: artifacts-*
merge-multiple: true
- name: Display Structure of Artifacts Files
run: ls -R
- name: Show Working Directory For Debug Purpose
run: |
pwd
ls -alht
ls -alht artifacts || exit 0
shell: bash
- name: Upload images to Release Asset
uses: softprops/action-gh-release@v1
with:
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.CR_PAT }}