Skip to content

Commit 654c7f4

Browse files
[skip-beta] Add deploy-stable action
1 parent 7539791 commit 654c7f4

File tree

4 files changed

+139
-1
lines changed

4 files changed

+139
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'Deploy stable'
2+
description: 'Deploys a stable version'
3+
inputs:
4+
trakt-tools-bot-token:
5+
description: 'Token for generating the release'
6+
required: true
7+
runs:
8+
using: 'node16'
9+
main: 'deploy-stable.js'
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const { getInput, setFailed } = require('@actions/core');
2+
const { getOctokit } = require('@actions/github');
3+
const fs = require('fs');
4+
const path = require('path');
5+
const packageJson = require('../../../package.json');
6+
7+
const defaultParams = {
8+
owner: packageJson.author,
9+
repo: packageJson.name,
10+
};
11+
12+
const deployStable = async () => {
13+
const octokit = getOctokit(getInput('trakt-tools-bot-token'), {
14+
userAgent: 'universal-trakt-scrobbler',
15+
});
16+
17+
console.log('Generating release...');
18+
19+
const name = `v${packageJson.version}`;
20+
21+
const release = await octokit.rest.repos.createRelease({
22+
...defaultParams,
23+
name,
24+
tag_name: packageJson.version,
25+
});
26+
27+
const distPath = path.resolve(__dirname, '../../../dist');
28+
const files = [
29+
{
30+
content: fs.readFileSync(path.resolve(distPath, 'chrome.zip')),
31+
name: 'chrome.zip',
32+
type: 'application/zip',
33+
},
34+
{
35+
content: fs.readFileSync(path.resolve(distPath, 'firefox.zip')),
36+
name: 'firefox.zip',
37+
type: 'application/zip',
38+
},
39+
];
40+
41+
console.log('Uploading assets...');
42+
43+
const promises = [];
44+
for (const file of files) {
45+
promises.push(
46+
octokit.rest.repos.uploadReleaseAsset({
47+
...defaultParams,
48+
release_id: release.data.id,
49+
name: file.name,
50+
data: file.content,
51+
url: release.data.upload_url,
52+
})
53+
);
54+
}
55+
await Promise.all(promises);
56+
57+
console.log('Publishing release...');
58+
59+
await octokit.rest.repos.updateRelease({
60+
...defaultParams,
61+
release_id: release.data.id,
62+
draft: false,
63+
});
64+
};
65+
66+
const main = async () => {
67+
try {
68+
await deployStable();
69+
} catch (err) {
70+
setFailed(err.message);
71+
}
72+
};
73+
74+
void main();

.github/workflows/deploy-beta.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
deploy_beta_version:
1010
name: Deploy beta version
11-
if: ${{ !contains(github.event.head_commit.message, '[skip-beta]') }}
11+
if: ${{ !contains(github.event.head_commit.message, '[skip-beta]') && !contains(github.event.head_commit.message, '[bump-version]') }}
1212
runs-on: ubuntu-22.04
1313
env:
1414
TRAKT_CLIENT_ID: ${{ secrets.TRAKT_CLIENT_ID }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy Stable
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy_stable_version:
10+
name: Deploy stable version
11+
if: ${{ contains(github.event.head_commit.message, '[bump-version]') }}
12+
runs-on: ubuntu-22.04
13+
env:
14+
TRAKT_CLIENT_ID: ${{ secrets.TRAKT_CLIENT_ID }}
15+
TRAKT_CLIENT_SECRET: ${{ secrets.TRAKT_CLIENT_SECRET }}
16+
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
17+
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
18+
CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
19+
CHROME_EXTENSION_KEY: ${{ secrets.CHROME_EXTENSION_KEY }}
20+
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: pnpm/action-setup@v2
24+
with:
25+
version: 7
26+
- uses: actions/setup-node@v3
27+
with:
28+
node-version: 16
29+
cache: pnpm
30+
- name: Install dependencies
31+
run: pnpm install
32+
- name: Build
33+
run: pnpm run build
34+
- name: Deploy version
35+
uses: ./.github/actions/deploy-stable
36+
with:
37+
trakt-tools-bot-token: '${{ secrets.TRAKT_TOOLS_BOT_TOKEN }}'
38+
- name: Upload to Chrome store
39+
continue-on-error: true
40+
uses: trmcnvn/chrome-addon@v2
41+
with:
42+
extension: ${{ secrets.CHROME_EXTENSION_ID }}
43+
zip: ./dist/chrome.zip
44+
client-id: ${{ secrets.CHROME_CLIENT_ID }}
45+
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
46+
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
47+
- name: Upload to Firefox store
48+
continue-on-error: true
49+
uses: trmcnvn/firefox-addon@v1
50+
with:
51+
uuid: ${{ secrets.FIREFOX_EXTENSION_ID }}
52+
xpi: ./dist/firefox.zip
53+
manifest: ./build/firefox/manifest.json
54+
api-key: ${{ secrets.FIREFOX_CLIENT_ID }}
55+
api-secret: ${{ secrets.FIREFOX_CLIENT_SECRET }}

0 commit comments

Comments
 (0)