-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbuild-release-alpine-nodejs.yml
More file actions
120 lines (115 loc) · 4.3 KB
/
build-release-alpine-nodejs.yml
File metadata and controls
120 lines (115 loc) · 4.3 KB
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
name: Build Alpine Node.js
permissions:
contents: write
on:
workflow_dispatch:
inputs:
NodeVersion:
required: true
description: 'Node.js version to build (ex: v12.22.7, v16.12.0)'
jobs:
build:
name: Build node.js ${{github.event.inputs.NodeVersion}}
runs-on: ubuntu-latest
strategy:
matrix:
arch: ['x64', 'arm64']
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: |
NodeVersion="${{github.event.inputs.NodeVersion}}"
PythonVersion="python3"
Arch="${{matrix.arch}}"
if [[ $NodeVersion = v12* ]]
then
PythonVersion="python2"
fi
DockerPlatform="linux/amd64"
if [[ $Arch = arm64 ]]
then
DockerPlatform="linux/arm64"
fi
echo node.js version $NodeVersion
echo python version $PythonVersion
echo arch $Arch
docker build --file Dockerfile --tag alpine_nodejs:${{github.event.inputs.NodeVersion}} --build-arg NodeVersion=${{github.event.inputs.NodeVersion}} --build-arg PythonVersion=$PythonVersion --build-arg Arch=$Arch --platform $DockerPlatform .
- name: Copy alpine node.js out
run: |
mkdir $RUNNER_TEMP/alpine_node
docker run --rm -v $RUNNER_TEMP/alpine_node:/node_output alpine_nodejs:${{github.event.inputs.NodeVersion}}
ls -l -R $RUNNER_TEMP/alpine_node
- name: Upload alpine node.js
uses: actions/upload-artifact@v3
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_${{matrix.arch}}
path: ${{runner.temp}}/alpine_node/node-${{github.event.inputs.NodeVersion}}-alpine-${{matrix.arch}}.tar.gz
test:
name: Test node.js ${{github.event.inputs.NodeVersion}}
needs: [build]
strategy:
matrix:
include:
- arch: x64
runs-on: ubuntu-latest
- arch: arm64
runs-on: ubuntu-latest # TODO: Add and use an ARM64 runner
runs-on: ${{matrix.runs-on}}
container: alpine
steps:
- name: Download alpine node.js
uses: actions/download-artifact@v3
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_${{matrix.arch}}
- run: |
ls -l
tar xzf ./node-${{github.event.inputs.NodeVersion}}-alpine-${{matrix.arch}}.tar.gz
ls -l -R
./bin/node -v
./bin/node -e "console.log('hello world')"
uname -a
ldd ./bin/node
name: Test node
release:
name: Create release for node.js ${{github.event.inputs.NodeVersion}}
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Download x64 alpine node.js
uses: actions/download-artifact@v3
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_x64
- name: Download arm64 alpine node.js
uses: actions/download-artifact@v3
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_arm64
# Create GitHub release
- uses: actions/create-release@master
id: createRelease
name: Create node.js ${{github.event.inputs.NodeVersion}} Alpine Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{github.event.inputs.NodeVersion}}"
release_name: "${{github.event.inputs.NodeVersion}}"
body: |
Alpine node.js ${{github.event.inputs.NodeVersion}}
# Upload release assets
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ${{ github.workspace }}/node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
asset_name: node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
asset_content_type: application/octet-stream
- name: Upload Release Asset # TODO: Verify if this works
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ${{ github.workspace }}/node-${{github.event.inputs.NodeVersion}}-alpine-arm64.tar.gz
asset_name: node-${{github.event.inputs.NodeVersion}}-alpine-arm64.tar.gz
asset_content_type: application/octet-stream