-
Notifications
You must be signed in to change notification settings - Fork 2
112 lines (93 loc) · 3.68 KB
/
release.yaml
File metadata and controls
112 lines (93 loc) · 3.68 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
on:
push:
branches:
- main
name: Release Packaging
env:
RUNNER_IMAGE_NAME: rustbot-runner
BOT_IMAGE_NAME: rustbot
PROJECT_NAME_UNDERSCORE: rustbot
jobs:
package:
name: Release Packaging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
target: x86_64-unknown-linux-musl
toolchain: stable
override: true
- name: Install RPM packager
run: cargo install cargo-generate-rpm
- name: Install MUSL Toolchain
run: sudo apt-get -y install musl-tools
- name: Build
run: |
cargo build --release --target x86_64-unknown-linux-musl
strip -s target/x86_64-unknown-linux-musl/release/*rustbot
cargo generate-rpm -o target/generate-rpm/rustbot-x86_64.rpm
- name: 'Upload Release Artifact'
uses: actions/upload-artifact@v2
with:
name: ${{ env.PROJECT_NAME_UNDERSCORE }}
path: |
target/x86_64-unknown-linux-musl/release/*rustbot*
target/x86_64-unknown-linux-musl/release/assets/*
LICENSE*
- name: 'Upload RPM Artifact'
uses: actions/upload-artifact@v2
with:
name: ${{ env.PROJECT_NAME_UNDERSCORE }}_rpm
path: |
target/generate-rpm/rustbot-x86_64.rpm
package-docker:
runs-on: ubuntu-latest
needs: package
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: ${{ env.PROJECT_NAME_UNDERSCORE }}_rpm
path: target/generate-rpm/
- name: Build runner image
run: docker build . --file runner.Dockerfile --tag $RUNNER_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Build bot image
run: docker build . --file bot.Dockerfile --tag $BOT_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
# This is where you will update the PAT to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push runner image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$RUNNER_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
docker tag $RUNNER_IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Push bot image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$BOT_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
docker tag $BOT_IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION