forked from tiainen/pyrsia_build_pipeline_prototype
-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (85 loc) · 3.67 KB
/
rust.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
---
name: Rust
on:
push:
branches: [main]
pull_request:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
build-push-linux:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-20.04
env:
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v3
# Use sscache store in GitHub cache
- uses: actions/cache@v3
with:
path: /home/runner/.cache/sccache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install and start sccache from binary
- name: Start sccache
run: |
.github/workflows/sccache-linux.sh
sccache --start-server
sccache --show-stats
- uses: pyrsia/rust-toolchain@v2
with:
packages: set-cargo-version
# Need to add build number to version number
- name: Add Build to Version Number
run: |
set-cargo-version Cargo.toml ${{ env.PKG_VERSION }}+${{ github.run_number }}
# Run cargo build in parallel using sscache to avoid OS locking errors
- name: Build Release and Test Binaries
run: |
cargo build --workspace --release
sccache --show-stats
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Docker Image for Pyrsia Build Service
uses: docker/build-push-action@v3
with:
context: .
push: true
file: installers/docker/BuildService.Dockerfile
tags: pyrsiaoss/pyrsia-build-service:${{ env.PKG_VERSION }}-${{ github.run_number }}
# Update the helm chart values with the image tag
- name: Add Build to Version Number in Chart and Values files
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
sudo go install github.com/mikefarah/yq/v4@latest
yq e '.image.tag |= "${{ env.PKG_VERSION }}-${{ github.run_number }}"' -i installers/helm/pyrsia-build-service/values.yaml
yq e '.version |= "${{ env.PKG_VERSION }}+${{ github.run_number }}"' -i installers/helm/pyrsia-build-service/Chart.yaml
yq e '.appVersion |= "${{ env.PKG_VERSION }}+${{ github.run_number }}"' -i installers/helm/pyrsia-build-service/Chart.yaml
# Login to GCS
- name: Google Auth
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/679352079717/locations/global/workloadIdentityPools/pyrsia-pool/providers/github-provider'
service_account: '[email protected]'
# Add gsutils
- name: Set up Cloud SDK
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/setup-gcloud@v1'
# Add the updated helm chart to the helm NIGHTLY repo
- name: Add the updated helm chart to the helm NIGHTLY repo
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
.github/workflows/chartmuseum.sh nightly
# Add the updated helm chart to the helm STABLE repo
- name: Add the updated helm chart to the helm STABLE repo
if: github.repository_owner == 'pyrsia' && github.event_name == 'release'
run: |
.github/workflows/chartmuseum.sh stable