forked from vincss/mcsleepingserverstarter
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (92 loc) · 2.93 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
# https://github.com/actions/create-release
# https://github.com/actions/upload-release-asset
name: Create release
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm run test --if-present
- name: Save executables
uses: actions/upload-artifact@v3
with:
name: bin
path: ./bin
retention-days: 1
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Retrieve saved executables
uses: actions/download-artifact@v3
with:
name: bin
path: ./bin
- run: |
set -x
assets=()
for asset in ./bin/*; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_docker:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Retrieve saved executables
uses: actions/download-artifact@v3
with:
name: bin
path: ./bin
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up QEMU (to support building for both amd64 and arm64)
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- run: |
mkdir ./docker/mcsleepingserverstarter-linux
cp ./bin/mcsleepingserverstarter-linux-x64 ./docker/mcsleepingserverstarter-linux/amd64
cp ./bin/mcsleepingserverstarter-linux-arm64 ./docker/mcsleepingserverstarter-linux/arm64
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
push: true
context: ./docker
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}