forked from f1xpl/aasdk
-
Notifications
You must be signed in to change notification settings - Fork 32
162 lines (157 loc) · 5.17 KB
/
build_compile.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
name: Build and test with docker
on:
push:
tags:
- '*'
jobs:
version:
outputs:
version: ${{ steps.get_version.outputs.version }}
buildname: ${{ steps.get_version.outputs.buildname }}
runs-on: "ubuntu-latest"
steps:
-
name: Checkout repository
uses: actions/checkout@v1
-
name: Get the version
id: get_version
run: |
if [ -z "$version" ]
then
version=$(date '+%Y%m%d')
echo ::set-output name=version::"${version}"
else
echo ::set-output name=version::"${version}"
fi
builddate=$(date '+%Y-%m-%d')
buildhash=$(git rev-parse --short "$GITHUB_SHA")
buildname="${builddate}-${buildhash}"
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildhash::${buildhash}
echo ::set-output name=builddate::${builddate}
echo ::set-output name=buildname::${buildname}
env:
version: ${{ github.event.inputs.version }}
compile:
runs-on: ${{ matrix.host }}
needs: [ version ]
strategy:
fail-fast: false
max-parallel: 3
matrix:
host: [
"ubuntu-latest",
#"macos-10.15",
]
config:
- {
name: "armhf Release",
arch: "armhf"
}
- {
name: "amd64 Release",
arch: "amd64"
}
name: 'Build and Upload release: ${{ matrix.config.name }}'
steps:
- uses: actions/checkout@v2
-
name: Build the Docker image
run: docker build -t aasdk_builder --file buildenv/Dockerfile .
-
name: 'Build ${{ matrix.config.arch }} Debian package'
run: docker run -v "${PWD}/release":/release aasdk_builder:latest ${{ matrix.config.arch }}
-
name: Get Name of Artifact
id: get-artifact-name
run: |
ls -hla
ARTIFACT_PATHNAME=$(ls ./release/*.deb | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
echo ::set-output name=artifact_filename::${ARTIFACT_NAME}
echo ::set-output name=artifact_path::${ARTIFACT_PATHNAME}
-
name: Upload build artifacts
id: upload_deploy
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.config.arch }}
path: |
${{ steps.get-artifact-name.outputs.artifact_path }}
# Create Release
release:
runs-on: ubuntu-latest
needs: [ version, compile ]
if: startsWith(github.ref, 'refs/tags/')
name: 'Create release'
outputs:
release_upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
steps:
- uses: actions/checkout@v2
-
name: Build Changelog
id: github_release
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Create GitHub release
id: create_release
uses: softprops/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{needs.version.outputs.version }}
release_name: ${{needs.version.outputs.buildname }}
body: ${{steps.github_release.outputs.changelog}}
draft: true
prerelease: true
# Upload release artifacts
upload:
needs: [ version, compile, release ]
runs-on: ${{ matrix.host }}
strategy:
fail-fast: false
max-parallel: 3
matrix:
host: [
"ubuntu-latest",
#"macos-10.15",
]
config:
- {
name: "armhf Release",
arch: "armhf"
}
- {
name: "amd64 Release",
arch: "amd64"
}
name: 'Upload release: ${{ matrix.config.name }}'
steps:
-
name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: ${{ steps.get_version.outputs.version }}
-
name: Get Artifact Filenames
id: get-artifact-name
run: |
ARTIFACT_PATHNAME=$(ls ${{ matrix.config.arch }}/*.deb | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
echo ::set-output name=artifact_filename::${ARTIFACT_NAME}
echo ::set-output name=artifact_path::${ARTIFACT_PATHNAME}
-
name: Upload zip to release
id: upload_zip
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.version.outputs.buildname }}
with:
upload_url: ${{needs.release.outputs.release_upload_url}}
asset_path: ${{ steps.get-artifact-name.outputs.artifact_path }}
asset_name: ${{ steps.get-artifact-name.outputs.artifact_filename }}
asset_content_type: application/vnd.debian.binary-package