207 lines (205 loc) · 6.94 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Release
on:
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'CONTRIBUTING.md'
- 'COPYING'
- 'docs/**'
- '.github/*.md'
- '.github/FUNDING.yml'
jobs:
release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.changelog.outputs.version }}
skipped: ${{ steps.changelog.outputs.skipped }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create changelog
id: changelog
uses: TriPSs/conventional-changelog-action@v3
with:
github-token: ${{ secrets.github_token }}
skip-version-file: "true"
output-file: "false"
skip-commit: "true"
skip-on-empty: "true"
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
if: ${{ steps.changelog.outputs.skipped == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
tag_name: ${{ steps.changelog.outputs.tag }}
release_name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}
artifacts:
needs: release
if: ${{ needs.release.outputs.skipped == 'false' }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
ARTIFACT: posh-linux-amd64
- os: macos-latest
ARTIFACT: posh-darwin-amd64
- os: windows-latest
ARTIFACT: posh-windows-amd64.exe
runs-on: ${{ matrix.os }}
outputs:
hash_linux: ${{ steps.hash.outputs.hash_ubuntu-latest }}
hash_macos: ${{ steps.hash.outputs.hash_macos-latest }}
hash_windows: ${{ steps.hash.outputs.hash_windows-latest }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: Build
id: build
run: go build -o ${{ matrix.ARTIFACT }} -ldflags="-X 'main.version= ${{ needs.release.outputs.version }}'"
env:
GOARCH: "amd64"
- name: Hash
id: hash
run: |
$fileHash = Get-FileHash ${{ matrix.ARTIFACT }} -Algorithm SHA256
$fileHash.Hash | Out-File -Encoding 'UTF8' ${{ matrix.ARTIFACT }}.sha256
Write-Output "::set-output name=hash_${{ matrix.os }}::$($fileHash.Hash)"
shell: pwsh
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ matrix.ARTIFACT }}
asset_name: ${{ matrix.ARTIFACT }}
asset_content_type: application/octet-stream
- name: Upload Hash Asset
id: upload-hash-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ matrix.ARTIFACT }}.sha256
asset_name: ${{ matrix.ARTIFACT }}.sha256
asset_content_type: text/plain
themes:
needs: release
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: ubuntu-latest
outputs:
hash_themes: ${{ steps.hash.outputs.hash_themes }}
defaults:
run:
shell: pwsh
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Zip theme files
run: |
$compress = @{
Path = "themes\*.json"
CompressionLevel = "Fastest"
DestinationPath = "themes.zip"
}
Compress-Archive @compress
- name: Hash
id: hash
run: |
$fileHash = Get-FileHash themes.zip -Algorithm SHA256
$fileHash.Hash | Out-File -Encoding 'UTF8' themes.zip.sha256
Write-Output "::set-output name=hash_themes::$($fileHash.Hash)"
- name: Upload Themes
id: upload-themes
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: themes.zip
asset_name: themes.zip
asset_content_type: application/octet-stream
- name: Upload Themes Hash
id: upload-hash-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: themes.zip.sha256
asset_name: themes.zip.sha256
asset_content_type: text/plain
homebrew:
needs: release
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: ubuntu-latest
env:
GH_KEY: ${{ secrets.GH_PAT }}
steps:
- name: Push Version
run: |
curl -XPOST -u "jandedobbeleer:$GH_KEY" \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Content-Type: application/json" https://api.github.com/repos/jandedobbeleer/homebrew-oh-my-posh/actions/workflows/release.yml/dispatches \
--data '{"ref": "main", "inputs": {"version": "${{ needs.release.outputs.version }}"} }'
powershell:
needs: [release, artifacts]
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
working-directory: ${{ github.workspace }}/packages/powershell/oh-my-posh
env:
PSGALLERY_KEY: ${{ secrets.PSGALLERY_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Pack and push
run: ./deploy.ps1 -BinVersion ${{ needs.release.outputs.version }} -ModuleVersion ${{ needs.release.outputs.version }} -Repository PSGallery -RepositoryAPIKey $env:PSGALLERY_KEY
scoop:
needs: [release, artifacts]
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
working-directory: ${{ github.workspace }}/packages/scoop
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update Template
run: ./build.ps1 -Version ${{ needs.release.outputs.version }}
- name: Upload Scoop JSON
id: upload-scoop-json
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/packages/scoop/oh-my-posh.json
asset_name: oh-my-posh.json
asset_content_type: text/plain
- name: Upload Scoop Archive
id: upload-scoop-post-install
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/packages/scoop/posh-windows-wsl-amd64.7z
asset_name: posh-windows-wsl-amd64.7z
asset_content_type: application/octet-stream