Skip to content

Commit 7b470d1

Browse files
committed
feat: staging changelogs
1 parent 832746e commit 7b470d1

File tree

4 files changed

+40
-30
lines changed

4 files changed

+40
-30
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ jobs:
199199
timezoneLinux: "America/Los_Angeles"
200200
- name: Checkout repo
201201
uses: actions/checkout@v4
202+
with:
203+
fetch-depth: 0
202204
- name: Download Unraid Web Components
203205
uses: actions/download-artifact@v4
204206
with:
@@ -209,6 +211,7 @@ jobs:
209211
run: |
210212
export API_VERSION=${{needs.build-test-api.outputs.API_VERSION}}
211213
export API_SHA256=${{needs.build-test-api.outputs.API_SHA256}}
214+
export PR=${{ github.event.pull_request.number }} || ""
212215
if [ -z "${API_VERSION}" ] ||
213216
[ -z "${API_SHA256}" ]; then
214217
echo "Error: One or more required variables are not set."

plugin/.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
API_VERSION=3.11.0
2-
API_SHA256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
3-
PR=35
1+
API_VERSION="3.11.1"
2+
API_SHA256="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
3+
PR="35"

plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"type": "module",
1010
"scripts": {
1111
"build-and-pack": "tsx scripts/build-plugin-and-txz.ts",
12-
"build:docker": "docker build -t unraid-api-plugin-builder . && docker run -v $(pwd)/deploy:/app/deploy -v $(pwd)/../.git:/app/deploy/.git unraid-api-plugin-builder",
12+
"build:docker": "docker build -t unraid-api-plugin-builder . && docker run -v $(pwd)/deploy:/app/deploy -v $(cd ../ && pwd)/.git:/app/.git unraid-api-plugin-builder",
1313
"prebuild:docker:test": "cp .env.example .env",
1414
"build:docker:test": "npm run build:docker",
1515
"postbuild:docker:test": "rm .env"

plugin/scripts/build-plugin-and-txz.ts

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const validatedEnv = envSchema.parse(env);
2020
const pluginName = "dynamix.unraid.net" as const;
2121
const startingDir = process.cwd();
2222

23+
// Ensure that git is available
24+
await $`git log -1 --pretty=%B`;
25+
2326
const createBuildDirectory = async () => {
2427
await execSync(`rm -rf deploy/pre-pack/*`);
2528
await execSync(`rm -rf deploy/release/*`);
@@ -100,16 +103,15 @@ const buildTxz = async (): Promise<{
100103
};
101104

102105
const getStagingChangelogFromGit = async (
103-
version: string
106+
apiVersion: string
104107
): Promise<string | null> => {
105108
try {
106109
const changelogStream = conventionalChangelog(
107110
{
108111
preset: "conventionalcommits",
109-
releaseCount: 0,
110112
},
111113
{
112-
version,
114+
version: apiVersion,
113115
}
114116
);
115117
let changelog = "";
@@ -161,13 +163,13 @@ const buildPlugin = async ({
161163
MAIN_TXZ = `https://preview.dl.unraid.net/unraid-api/pr/${pr}/${pluginName}-${version}.txz`;
162164
API_TGZ = `https://preview.dl.unraid.net/unraid-api/pr/${pr}/unraid-api-${process.env.API_VERSION}.tgz`;
163165
PLUGIN_URL = `https://preview.dl.unraid.net/unraid-api/pr/${pr}/${pluginName}.plg`;
164-
RELEASE_NOTES = await getStagingChangelogFromGit(version);
166+
RELEASE_NOTES = await getStagingChangelogFromGit(apiVersion);
165167
break;
166168
case "staging":
167169
PLUGIN_URL = "https://stable.dl.unraid.net/unraid-api/&name;.plg";
168170
MAIN_TXZ = `https://preview.dl.unraid.net/unraid-api/${pluginName}-${version}.txz`;
169171
API_TGZ = `https://preview.dl.unraid.net/unraid-api/unraid-api-${process.env.API_VERSION}.tgz`;
170-
RELEASE_NOTES = await getStagingChangelogFromGit(version);
172+
RELEASE_NOTES = await getStagingChangelogFromGit(apiVersion);
171173
break;
172174
}
173175

@@ -211,30 +213,35 @@ const buildPlugin = async ({
211213
/**
212214
* Main build script
213215
*/
214-
await createBuildDirectory();
215-
const { sha256: txzSha256, version } = await buildTxz();
216-
const { API_VERSION, API_SHA256, PR } = validatedEnv;
217-
await buildPlugin({
218-
type: "staging",
219-
txzSha256,
220-
version,
221-
apiVersion: API_VERSION,
222-
apiSha256: API_SHA256,
223-
});
224-
if (PR) {
216+
217+
const main = async () => {
218+
await createBuildDirectory();
219+
const { sha256: txzSha256, version } = await buildTxz();
220+
const { API_VERSION, API_SHA256, PR } = validatedEnv;
225221
await buildPlugin({
226-
type: "pr",
222+
type: "staging",
227223
txzSha256,
228224
version,
229-
pr: PR,
230225
apiVersion: API_VERSION,
231226
apiSha256: API_SHA256,
232227
});
233-
}
234-
await buildPlugin({
235-
type: "production",
236-
txzSha256,
237-
version,
238-
apiVersion: API_VERSION,
239-
apiSha256: API_SHA256,
240-
});
228+
if (PR) {
229+
await buildPlugin({
230+
type: "pr",
231+
txzSha256,
232+
version,
233+
pr: PR,
234+
apiVersion: API_VERSION,
235+
apiSha256: API_SHA256,
236+
});
237+
}
238+
await buildPlugin({
239+
type: "production",
240+
txzSha256,
241+
version,
242+
apiVersion: API_VERSION,
243+
apiSha256: API_SHA256,
244+
});
245+
};
246+
247+
await main();

0 commit comments

Comments
 (0)