-
Notifications
You must be signed in to change notification settings - Fork 26
118 lines (102 loc) · 3.67 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
name: Release
on:
workflow_dispatch:
inputs:
run-id:
description: 'The CI workflow run ID with the artifacts to release'
required: true
concurrency: picky-release
jobs:
preflight:
name: Preflight
runs-on: ubuntu-20.04
outputs:
commit: ${{ steps.get-commit.outputs.commit }}
steps:
- name: Get commit
id: get-commit
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$RunJson = gh api /repos/devolutions/picky-rs/actions/runs/${{ github.event.inputs.run-id }}
$Run = $RunJson | ConvertFrom-Json
echo "commit=$($Run.head_sha)" >> $Env:GITHUB_OUTPUT
- name: Print output
shell: pwsh
run: Write-Host Run ${{ github.event.inputs.run-id }} - Commit ${{ steps.get-commit.outputs.commit }}
containers:
name: Containers [${{ matrix.os }} ${{ matrix.base-image }}]
runs-on: ${{ matrix.runner }}
environment: build-and-publish
needs: preflight
strategy:
fail-fast: true
matrix:
arch: [ x86_64 ]
os: [ windows, linux ]
base-image: [buster, servercore-ltsc2019, nanoserver-1809 ]
include:
- os: windows
runner: windows-2019
- os: linux
runner: ubuntu-18.04
exclude:
- os: windows
base-image: buster
- os: linux
base-image: servercore-ltsc2019
- os: linux
base-image: nanoserver-1809
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.commit }}
- name: Rename picky-server directory
shell: pwsh
run: Rename-Item -Path picky-server -NewName server -Force
- name: Get version
id: get-version
shell: pwsh
run: |
$Data = Select-String -Pattern 'version' $(Join-Path server Cargo.toml) | Select-Object -First 1
$Data -Match "(\d*\.\d*\.\d*)"
echo "version=$($matches[0])" >> $Env:GITHUB_OUTPUT
- name: Download and copy artifacts
id: download
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run download ${{ github.event.inputs.run-id }} --dir "$Env:RUNNER_TEMP" --name picky
$SourceFile = "picky-server"
if ($Env:RUNNER_OS -Eq "Windows") {
$SourceFile = "$($SourceFile).exe"
}
$SourcePath = Join-Path "$Env:RUNNER_TEMP" ${{ matrix.os }} ${{ matrix.arch }} $SourceFile
$TargetPath = Join-Path $pwd $SourceFile
Copy-Item $SourcePath $TargetPath
if ($Env:RUNNER_OS -eq "Linux") {
Invoke-Expression "chmod +x $TargetPath"
}
- name: Build container
id: build-container
shell: pwsh
run: |
$ImageName = "devolutions/picky:${{ steps.get-version.outputs.version }}-${{ matrix.base-image }}"
if ($Env:RUNNER_OS -Eq "Windows") {
if ("${{ matrix.base-image }}" -Eq "nanoserver-1809") {
docker build --build-arg FROM_IMAGE=mcr.microsoft.com/windows/nanoserver:1809 -t "$ImageName" -f DockerFile-win2k19 .
} else {
docker build -t "$ImageName" -f DockerFile-win2k19 .
}
} else {
docker build -t "$ImageName" .
}
echo "image-name=$ImageName" >> $Env:GITHUB_OUTPUT
- name: Push container
shell: pwsh
run: |
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u devolutionsbot --password-stdin
docker push ${{ steps.build-container.outputs.image-name }}