-
Notifications
You must be signed in to change notification settings - Fork 3
129 lines (112 loc) · 3.45 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build and Release
on: push
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
include:
- os: ubuntu-latest
image: ubuntu:latest
- os: macos-latest
image: macos-latest
#- os: windows-latest
#image: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build on Linux and macOS
if: matrix.os != 'windows-latest'
run: |
gcc await.c -o await -lpthread
- name: Build on Windows
if: matrix.os == 'windows-latest'
run: |
gcc await.c -o await.exe -lpthread
- name: Generate autocompletion scripts
run: |
mkdir -p releases
mkdir -p autocompletions
./await --autocomplete-fish > autocompletions/await.fish
./await --autocomplete-bash > autocompletions/await.bash
./await --autocomplete-zsh > autocompletions/await.zsh
- name: Move binary to release directory
run: |
if [ ${{ matrix.os }} == 'windows-latest' ]; then
mv await.exe releases/await_${{ github.ref_name }}_windows_amd64.exe
elif [ ${{ matrix.os }} == 'macos-latest' ]; then
mv await releases/await_${{ github.ref_name }}_macos_amd64
else
mv await releases/await_${{ github.ref_name }}_linux_amd64
fi
- name: Upload Autocompletion Scripts
uses: actions/upload-artifact@v2
with:
name: autocompletions
path: autocompletions
- name: Upload Binary
uses: actions/upload-artifact@v2
with:
name: await-${{ matrix.os }}
path: releases/*
- name: Set dummy ACTIONS_RUNTIME_TOKEN and ACTIONS_RUNTIME_URL for act
if: ${{ env.ACT }}
run: |
echo "ACTIONS_RUNTIME_TOKEN=dummy_token" >> $GITHUB_ENV
echo "ACTIONS_RUNTIME_URL=https://dummy_url" >> $GITHUB_ENV
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check if Release Exists
id: check_release
run: |
gh release view v1.0.5 || echo "Release does not exist"
- name: Create or Update Release
id: create_update_release
if: steps.check_release.outputs.exists == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v1.0.5
release_name: v1.0.5
body: Fixed ctrl-c handling when it's run from bash script
draft: false
prerelease: false
- name: Update Release Binaries
if: steps.check_release.outputs.exists == 'true'
run: |
gh release upload v1.0.5 releases/* --clobber
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: await-macos-latest
path: releases
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: await-ubuntu-latest
path: releases
- name: Download Autocompletion Scripts
uses: actions/download-artifact@v2
with:
name: autocompletions
path: autocompletions
- name: Upload Release Artifacts
uses: softprops/action-gh-release@v1
with:
files: |
releases/*
releases/await.*
autocompletions/*
tag_name: v1.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}