This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (89 loc) · 2.71 KB
/
build_and_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
---
name: Build and release
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-18.04
strategy:
matrix:
artifact: [ "service" ]
name: Build ${{ matrix.artifact }}
steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v1
with:
go-version: '1.14'
- name: Build binary
run: go build
- name: Prepare artifact
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir ${{ runner.temp }}/artifacts
cp ${{ matrix.artifact }} ${{ runner.temp }}/artifacts
- name: Updload artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.artifact }}
path: ${{ runner.temp }}/artifacts
draft-release:
runs-on: ubuntu-18.04
needs: build
name: Create draft release
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
id: ${{ steps.create_release.outputs.id }}
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
upload-artifacts:
name: Upload artifacts
runs-on: ubuntu-18.04
needs: draft-release
strategy:
matrix:
artifact: [ "service" ]
steps:
- name: Checkout code
uses: actions/checkout@master
- run: mkdir ${{ runner.temp }}/artifacts
- uses: actions/download-artifact@v4.1.7
with:
name: ${{ matrix.artifact }}
path: ${{ runner.temp }}/artifacts
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.draft-release.outputs.upload_url }}
asset_path: ${{ runner.temp }}/artifacts/${{ matrix.artifact }}
asset_name: ${{ matrix.artifact }}
asset_content_type: application/octet-stream
release:
runs-on: ubuntu-18.04
needs: [upload-artifacts, draft-release]
name: Create release
steps:
- uses: actions/github-script@0.9.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.draft-release.outputs.id }},
draft: false
})