Repository navigation
57 lines (50 loc) · 1.99 KB
/
Copy pathrelease.yml
File metadata and controls
57 lines (50 loc) · 1.99 KB
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
name: Release
on:
push:
tags: ["v*"]
# Re-run the packaging of an existing tag: choose the tag as the ref.
workflow_dispatch:
permissions:
contents: write
jobs:
release:
name: Build portable package
runs-on: windows-latest
env:
CGO_ENABLED: "0"
GOFLAGS: -mod=vendor
GOPROXY: "off"
GOTOOLCHAIN: local
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.27.3"
cache: false
- name: Test
run: go test ./...
- name: Assemble package
shell: pwsh
run: |
$version = '${{ github.ref_name }}'
$name = "deviceshell-$version-windows-amd64"
$root = Join-Path $env:RUNNER_TEMP $name
New-Item -ItemType Directory -Path $root | Out-Null
go build -trimpath -ldflags "-s -w" -o (Join-Path $root 'deviceshell.exe') ./cmd/deviceshell
if ($LASTEXITCODE -ne 0) { exit 1 }
Copy-Item configs/config.example.json (Join-Path $root 'config.json')
Copy-Item configs/routines (Join-Path $root 'routines') -Recurse
Copy-Item LICENSE, THIRD_PARTY_NOTICES.md, README.md -Destination $root
./scripts/fetch-tools.ps1 -Root $root
$zip = Join-Path $env:RUNNER_TEMP "$name.zip"
Compress-Archive -Path $root -DestinationPath $zip
# LF line ending, so `sha256sum -c` accepts it on any system.
[IO.File]::WriteAllText("$zip.sha256", (Get-FileHash $zip -Algorithm SHA256).Hash.ToLower() + " $name.zip`n")
"ZIP=$zip" | Add-Content $env:GITHUB_ENV
- name: Publish release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$notes = "See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md) for what changed."
gh release create '${{ github.ref_name }}' $env:ZIP "$env:ZIP.sha256" --title 'DeviceShell ${{ github.ref_name }}' --notes $notes --verify-tag