-
Notifications
You must be signed in to change notification settings - Fork 19
96 lines (84 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
name: CI Workflow
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: |
make
- name: Upload artifacts
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
uses: actions/upload-artifact@v4
with:
name: artifact
path: ./dist/artifacts/*
- name: Get code info
id: info
run: |
source scripts/version
echo "::set-output name=artifacts_dir::${PWD}/dist/artifacts"
echo "::set-output name=version::$(echo $GITHUB_REF | cut -d / -f 3)"
echo "::set-output name=base_version::${VERSION}"
- name: Generate release info
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
env:
BASE_VERSION: ${{ steps.info.outputs.base_version }}
run: |
echo "🍻" > release.txt
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
body_path: release.txt
files: ${{ steps.info.outputs.artifacts_dir }}/*
publish-gcp:
name: Publish artifacts to GCP
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
permissions:
contents: read
id-token: write # for reading credential https://github.com/rancher-eio/read-vault-secrets
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifact
path: ./dist/artifacts/
- name: Read Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/google-auth/harvester/credentials token | GOOGLE_AUTH ;
- name: Login to Google Cloud
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ env.GOOGLE_AUTH }}'
- name: Publish master
uses: 'google-github-actions/upload-cloud-storage@v2'
if: startsWith(github.ref, 'refs/heads/master')
with:
path: dist/artifacts
parent: false
destination: releases.rancher.com/harvester-node-driver/master
predefinedAcl: publicRead
headers: |-
cache-control: public,no-cache,proxy-revalidate
- name: Publish tag
uses: 'google-github-actions/upload-cloud-storage@v2'
if: startsWith(github.ref, 'refs/tags/')
with:
path: dist/artifacts
parent: false
destination: releases.rancher.com/harvester-node-driver/${{ github.ref_name }}
predefinedAcl: publicRead
headers: |-
cache-control: public,no-cache,proxy-revalidate