Skip to content

Commit 73a51f2

Browse files
authored
Merge pull request #415 from processing/improved-fetchreleases
Improved fetchreleases
2 parents c16d62f + c79db18 commit 73a51f2

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

docs/download.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ In order to not require an API token on GitHub in development, there is a separa
66

77
## How to show a new release on the download page
88

9-
1. Make sure `npm` is up to date
9+
1. Make sure `npm` is up to date. (Check Node.js version with `node -v` and make sure it corresponds to the version in [`/.github/workflows/deploy.yml`](https://github.com/processing/processing-website/blob/main/.github/workflows/deploy.yml). For example, if the version specified in the deploy.yml file is `node-version: 16.x` then `v16.17.0` would be a match.)
1010
1. Make sure that the release has been published on GitHub
11-
1. Run the script with a GitHub token: `$ GITHUB_TOKEN=SOMETOKENHERE npm run fetchReleases`
12-
1. Edit the [`selected.json`](/content/download/selected.json) file to include the new release tag
13-
1. Make a PR to the `main` branch.
11+
1. Create a [GitHub access token](https://github.com/settings/tokens)
12+
1. Create a git branch to hold your changes
13+
1. Run the script with: `npm run fetchReleases`
14+
1. Enter your GitHub access token when prompted
15+
1. Edit the [`/content/download/selected.json`](/content/download/selected.json) file to include the new release tag
16+
1. Make a pull request to the `main` branch

scripts/fetchReleases.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
const readline = require('readline');
12
const { graphql } = require('@octokit/graphql');
23
const fs = require('fs');
34
const path = require('path');
45

5-
const fetchReleases = async () => {
6+
const fetchReleases = async (githubToken) => {
67
const { processing, processing4 } = await graphql(
78
`
89
query {
@@ -48,7 +49,7 @@ const fetchReleases = async () => {
4849
`,
4950
{
5051
headers: {
51-
authorization: `token ${process.env.GITHUB_TOKEN}`
52+
authorization: `token ${githubToken}`
5253
}
5354
}
5455
);
@@ -71,10 +72,14 @@ const fetchReleases = async () => {
7172
});
7273
};
7374

74-
// only fetch if ENV has GITHUB_TOKEN
75-
if (process.env.GITHUB_TOKEN) {
75+
const rl = readline.createInterface({
76+
input: process.stdin,
77+
output: process.stdout
78+
});
79+
80+
rl.question('Please enter your GitHub token: ', (token) => {
81+
rl.close();
82+
7683
console.log('Fetching releases from github.com');
77-
fetchReleases();
78-
} else {
79-
console.log('No GitHub token found. Bypassing fetch of releases');
80-
}
84+
fetchReleases(token);
85+
});

0 commit comments

Comments
 (0)