-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (129 loc) · 4.35 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Inspired by https://github.com/kowainik/stan/blob/30ae41dccde49feefe19913039014f3612e5d44c/.github/workflows/release.yml
name: Release
permissions:
contents: write
on:
push:
tags:
- "v*"
jobs:
create_release:
name: Create Github Release
runs-on: ubuntu-latest
steps:
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="$tag" \
--generate-notes \
--draft
build_artifact:
needs: [create_release]
name: ${{ matrix.os }}/${{ matrix.arch }}/${{ github.ref }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
- os: macOS-13 # macOS-latest does something weird I don't understand
arch: aarch64
- os: windows-latest
arch: x86_64
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set tag name
uses: olegtarasov/get-tag@v2.1.4
id: tag
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: Setup Haskell
uses: haskell-actions/setup@v2.7.9
with:
ghc-version: 9.6.5
enable-stack: true
stack-version: 2.15.7
- name: Cache ~/.stack
uses: actions/cache@v4
with:
path: ~/.stack
key: ${{ runner.os }}-9.6.5-${{ matrix.arch }}-${{ hashFiles('**/stack.yaml.lock','**/gitlab-helper.cabal') }}-v2
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-9.6.5-
- name: Build binary
run: |
mkdir bin
stack build --copy-bins --local-bin-path bin
- if: matrix.os == 'windows-latest'
name: Set binary path name on Windows
run: |
echo "BINARY_PATH=./bin/gitlab-helper.exe" >> $env:GITHUB_ENV
- if: matrix.os != 'windows-latest'
name: Set binary path name not on Windows
run: |
echo "BINARY_PATH=./bin/gitlab-helper" >> "$GITHUB_ENV"
- if: matrix.os != 'macOS-13'
name: Compress binary
uses: svenstaro/upx-action@2.4.1
with:
files: ${{ env.BINARY_PATH }}
- if: matrix.os == 'windows-latest'
name: Set zip file path name on Windows
run: |
echo "ZIP_PATH=./bin/gitlab-helper-${{ steps.tag.outputs.tag }}-${{ runner.os }}.zip" >> $env:GITHUB_ENV
- if: matrix.os != 'windows-latest'
name: Set zip file path name not on Windows
run: |
echo "ZIP_PATH=./bin/gitlab-helper-${{ steps.tag.outputs.tag }}-${{ runner.os }}.zip" >> "$GITHUB_ENV"
- if: matrix.os != 'windows-latest'
name: Create zip file not on windows
run: |
7z a -l ${{ env.ZIP_PATH }} ${{ env.BINARY_PATH }}
- if: matrix.os == 'windows-latest'
name: Create zip file on windows
run: |
7z a ${{ env.ZIP_PATH }} ${{ env.BINARY_PATH }}
- name: Upload Release Asset
id: upload-release-asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ github.ref_name }}" "${{ env.ZIP_PATH }}#${{ runner.os }}.zip" --repo="$GITHUB_REPOSITORY"
test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
# - os: macOS-13
- os: windows-latest
name: Test built binaries
runs-on: ${{ matrix.os }}
needs: build_artifact
steps:
- # Apparently, gh requires to live in a git repo in order to work on windows
if: matrix.os == 'windows-latest'
name: Check out code
uses: actions/checkout@v4
- name: Set tag name
uses: olegtarasov/get-tag@v2.1.4
id: tag
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: download and extract executable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download "${{ github.ref_name }}" --pattern '*${{ runner.os }}.zip' --repo="$GITHUB_REPOSITORY" --output artifact.zip
7z e artifact.zip
- name: smoke test
run: |
./gitlab-helper --api-token "dummy" --group-id 123 --base-url "https://gitlab.example.com" version