-
Notifications
You must be signed in to change notification settings - Fork 9
125 lines (110 loc) · 4.02 KB
/
release-kernel.yml
File metadata and controls
125 lines (110 loc) · 4.02 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
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
# Example from https://github.com/actions/runner/blob/8db8bbe13a0dabc165d0ff19a1ecb85a4fe86dd8/.github/workflows/release.yml
name: Release
on:
workflow_dispatch:
inputs:
artifact-name:
type: string
required: true
kernel-version:
type: string
required: true
proxmox-version:
type: string
required: true
workflow_call:
inputs:
artifact-name:
type: string
required: true
kernel-version:
type: string
required: true
proxmox-version:
type: string
required: true
secrets:
token:
description: 'Token used in git operations'
required: true
env:
TOKEN: ${{ secrets.token }}
jobs:
release:
name: Release Built Kernel
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Set Git token (if needed)
if: env.TOKEN == ''
env:
TOK: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "TOKEN=${TOK}" > $GITHUB_ENV
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: ./assets
- name: Create Release Notes
id: create-release-notes
uses: actions/github-script@v6
with:
github-token: ${{ env.TOKEN }}
script: |
const fs = require('fs')
var releaseNote = fs.readFileSync('${{ github.workspace }}/release-notes.md', 'utf8')
releaseNote = releaseNote.replace(/<KERNEL_VERSION>/g, '${{ inputs.kernel-version }}')
releaseNote = releaseNote.replace(/<PROXMOX_VERSION>/g, '${{ inputs.proxmox-version }}')
console.log(releaseNote)
core.setOutput('release-note', releaseNote)
- name: Create release tag
uses: actions/github-script@v6
with:
script: |
const tagName = "${{ inputs.kernel-version }}";
const branch = "main";
const tagger = {
name: "Github Actions",
email: "github-actions@github.com"
};
const { owner, repo } = context.repo;
console.log("Finding out the HEAD sha");
let ref = `heads/${branch}`;
const head = await github.rest.git.getRef({ owner, repo, ref });
const sha = head.data.object.sha;
const message = "PVE kernel ${{ inputs.kernel-version }}-relaxablermrr release (Proxmox VE ${{ inputs.proxmox-version }})"
// Create tag object. This is only needed for annotated tags
console.log(`Creating tag ${tagName}`);
const newTag = await github.rest.git.createTag({
owner,
repo,
tag: tagName,
message,
object: sha,
type: "commit",
tagger
});
// Create tag reference
ref = `refs/tags/${tagName}`;
console.log(`Creating ref for tag ${tagName} (${newTag.data.sha})`);
const newRef = await github.rest.git.createRef({ owner, repo, ref, sha: newTag.data.sha });
# Using action-gh-release from https://github.com/softprops/action-gh-release
- name: Release
uses: softprops/action-gh-release@v1
#if: startsWith(github.ref, 'refs/tags/')
with:
#repository: brunokc/pve-kernel-builder
name: "Proxmox VE kernel ${{ inputs.kernel-version }}-relaxablermrr (Proxmox VE ${{ inputs.proxmox-version }})"
body: ${{ steps.create-release-notes.outputs.release-note }}
# Note: you'll typically need to create a personal access token
# with permissions to create releases in the other repo
#token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
token: ${{ env.TOKEN }}
tag_name: ${{ inputs.kernel-version }}
draft: true
fail_on_unmatched_files: true
files: ./assets/*.deb