-
Notifications
You must be signed in to change notification settings - Fork 66
153 lines (127 loc) · 4.57 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
name: Release
on:
push:
tags:
- "*-?v[0-9]+*"
env:
REGISTRY: ghcr.io
permissions:
contents: write
packages: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create or update release
uses: actions/github-script@v7
env:
TAG_NAME: ${{ github.ref_name }}
with:
script: |
const tag = process.env.TAG_NAME || github.ref_name;
const repo = context.repo;
const majorVersion = tag.match(/v(\d+)\.\d+\.\d+/)[1];
const releaseName = `Version ${majorVersion}`;
const date = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
const dynamicBody = `<!-- DYNAMIC START -->\n*Created from tag*: \`${tag}\`\n*Created from git revision*: \`${context.sha}\`\n*Published on*: \`${date}\`\n<!-- DYNAMIC END -->`;
async function findOrCreateRelease() {
const { data: releases } = await github.rest.repos.listReleases(repo);
let existingRelease = releases.find(release => release.name === releaseName);
if (existingRelease) {
const existingBody = existingRelease.body;
const newBody = existingBody.replace(/<!-- DYNAMIC START -->[^]*<!-- DYNAMIC END -->/, dynamicBody);
await github.rest.repos.updateRelease({
...repo,
release_id: existingRelease.id,
tag_name: tag,
body: newBody
});
console.log("Release updated to associate with new tag.");
} else {
const fullBody = `${dynamicBody}\n\n## Release Notes\n\n- Some bug fixes.`;
await github.rest.repos.createRelease({
...repo,
tag_name: tag,
name: releaseName,
body: fullBody,
draft: false,
prerelease: false
});
console.log("Release created successfully.");
}
}
findOrCreateRelease();
docker-release:
runs-on: ubuntu-latest
needs: create-release
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get docker image name and build args
id: required_args
run: |
image_name="${{ env.REGISTRY }}/${{ github.actor }}/${{ github.event.repository.name }}"
image_names="$image_name:${{ github.ref_name }},$image_name:latest"
# lowercase the name
image_names=$(echo "$image_names" | tr '[:upper:]' '[:lower:]')
echo "image_names=$image_names" >> $GITHUB_OUTPUT
- name: Build and push to ghcr
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.required_args.outputs.image_names }}
upload-kodi-plugin:
runs-on: ubuntu-20.04
needs: docker-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Setup Moon
uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- name: Build plugin
run: moon run kodi:build
- name: Upload plugin to releases
run: gh release upload --clobber ${{ github.ref_name }} "tmp/script.ryot.zip"
deploy-demo-instance:
runs-on: ubuntu-latest
needs: docker-release
steps:
- uses: actions/checkout@v4
- name: Set up CLI
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy
run: flyctl deploy --remote-only --detach --config ci/fly.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy-docs:
runs-on: ubuntu-latest
needs: docker-release
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Install dependencies
run: poetry install
- name: Deploy to github pages
run: poetry run mkdocs gh-deploy --force