Skip to content

Commit b83371b

Browse files
committed
test version
1 parent 5607776 commit b83371b

File tree

2 files changed

+99
-36
lines changed

2 files changed

+99
-36
lines changed

.github/workflows/gh-pages.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ jobs:
123123
run: ls -l
124124
- name: Debug VERSION
125125
run: |
126-
VERSION=$VERSION
127-
echo "VERSION is: ${VERSION}"
126+
echo "VERSION is: ${{ env.VERSION }}"
128127
env:
129128
VERSION: ${{ env.VERSION }}
130129
- name: Create GitHub Release
@@ -135,14 +134,15 @@ jobs:
135134
VERSION: ${{ env.VERSION }}
136135
with:
137136
tag_name: ${{ github.ref_name }}-${{ github.run_id }}
138-
release_name: Release v $VERSION
137+
release_name: Release v${{ env.VERSION }}
139138
draft: false
140139
prerelease: false
141140

142141
- name: Find All Files Matching VERSION
143142
id: find_files
144143
run: |
145-
VERSION=${{env.VERSION}}
144+
VERSION=${{ env.VERSION }}
145+
# Locate all files matching the VERSION
146146
files=($(ls ./*${VERSION}* 2>/dev/null || echo ""))
147147
if [ ${#files[@]} -eq 0 ]; then
148148
echo "Error: No files found matching VERSION ${VERSION}"
@@ -158,12 +158,12 @@ jobs:
158158
uses: actions/upload-release-asset@v1
159159
with:
160160
upload_url: ${{ steps.create_release.outputs.upload_url }} # Use the upload URL from the create-release step
161-
asset_path: $file # Adjust the path if necessary
161+
asset_path: ./*${{ env.file }}* # Adjust the path if necessary
162162
asset_name: ${{ env.VERSION }}-asset # Name of the asset to upload
163163
asset_content_type: application/octet-stream
164164
env:
165-
file: ${{ env.file }}
166165
VERSION: ${{ env.VERSION }}
166+
file: ${{ env.file }}
167167

168168

169169
# - name: Upload Windows Installer

src/component/TransferFunc.js

Lines changed: 93 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
import React, { Component } from 'react';
2-
import { Container, Paper, Typography, Button, Grid, TextField } from '@material-ui/core';
1+
import React, {
2+
Component
3+
} from 'react';
4+
import {
5+
Container,
6+
Paper,
7+
Typography,
8+
Button,
9+
Grid,
10+
TextField
11+
} from '@material-ui/core';
312
import axios from 'axios';
4-
import { MathJax, MathJaxContext } from 'better-react-mathjax';
13+
import {
14+
MathJax,
15+
MathJaxContext
16+
} from 'better-react-mathjax';
517
import Plot from 'react-plotly.js'; // Import Plotly component
618
import * as TransferFuncVar from './TransferFuncVar.js';
719
import HomeIcon from "@material-ui/icons/Home";
@@ -14,7 +26,7 @@ class TransferFunc extends Component {
1426
A: TransferFuncVar.A,
1527
B: TransferFuncVar.B,
1628
C: TransferFuncVar.C,
17-
version: packagejson.version,
29+
version: packagejson.version,
1830
token: '',
1931
errorA: false,
2032
errorB: false,
@@ -27,48 +39,80 @@ class TransferFunc extends Component {
2739
// Validation function
2840
validateInputs = () => {
2941
let valid = true;
30-
const { A, B, C, token, version } = this.state;
42+
const {
43+
A,
44+
B,
45+
C,
46+
token,
47+
version
48+
} = this.state;
3149

3250
if (!A || isNaN(A)) {
33-
this.setState({ errorA: true });
51+
this.setState({
52+
errorA: true
53+
});
3454
valid = false;
3555
} else {
36-
this.setState({ errorA: false });
56+
this.setState({
57+
errorA: false
58+
});
3759
}
3860

3961
if (!B || isNaN(B)) {
40-
this.setState({ errorB: true });
62+
this.setState({
63+
errorB: true
64+
});
4165
valid = false;
4266
} else {
43-
this.setState({ errorB: false });
67+
this.setState({
68+
errorB: false
69+
});
4470
}
4571

4672
if (!C || isNaN(C)) {
47-
this.setState({ errorC: true });
73+
this.setState({
74+
errorC: true
75+
});
4876
valid = false;
4977
} else {
50-
this.setState({ errorC: false });
78+
this.setState({
79+
errorC: false
80+
});
5181
}
5282

5383
if (!version) {
54-
this.setState({ errorVersion: true });
84+
this.setState({
85+
errorVersion: true
86+
});
5587
valid = false;
5688
} else {
57-
this.setState({ errorVersion: false });
89+
this.setState({
90+
errorVersion: false
91+
});
5892
}
5993

6094
if (!token) {
61-
this.setState({ errorToken: true });
95+
this.setState({
96+
errorToken: true
97+
});
6298
valid = false;
6399
} else {
64-
this.setState({ errorToken: false });
100+
this.setState({
101+
errorToken: false
102+
});
65103
}
66104

67105
return valid;
68106
};
69107

70108
uploadVar = async () => {
71-
const { A, B, C, token } = this.state;
109+
const {
110+
A,
111+
B,
112+
C,
113+
token,
114+
version
115+
} = this.state;
72116

73117
if (!this.validateInputs()) return;
74118

@@ -80,8 +124,7 @@ class TransferFunc extends Component {
80124
const getFileSHA = async () => {
81125
try {
82126
const res = await axios.get(
83-
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/${filePath}?ref=${branch}`,
84-
{
127+
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/${filePath}?ref=${branch}`, {
85128
headers: {
86129
Authorization: `token ${token}`,
87130
},
@@ -94,28 +137,48 @@ class TransferFunc extends Component {
94137
}
95138
};
96139

97-
this.setState({ loading: true }); // Set loading to true before making the request
140+
this.setState({
141+
loading: true
142+
});
98143
const sha = await getFileSHA();
99-
console.log('File SHA:', sha);
100-
this.setState({ loading: false }); // Reset loading after the request is done
144+
this.setState({
145+
loading: false
146+
}); // Reset loading after the request is done
101147
const updatedContent = `
102-
export const A = ${A};
103-
export const B = ${B};
104-
export const C = ${C};
105-
`;
148+
export const A = ${A};
149+
export const B = ${B};
150+
export const C = ${C};
151+
`;
106152

107153
const content = btoa(unescape(encodeURIComponent(updatedContent))); // Convert text to base64
154+
const updatedPackageJson = {
155+
...packagejson, // Current content
156+
version: version, // New version
157+
};
158+
159+
const updatedPackageJsonContent = JSON.stringify(updatedPackageJson, null, 2); // Format the JSON
160+
161+
const contentPackageJson = btoa(unescape(encodeURIComponent(updatedPackageJsonContent))); // Base64 encode
108162

109163
try {
110164
const response = await axios.put(
111-
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/${filePath}`,
112-
{
165+
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/${filePath}`, {
113166
message: sha ? 'Update TransferFuncVar.js file' : 'Create TransferFuncVar.js file',
114167
content: content,
115-
sha: sha,
116168
branch: branch,
117-
},
118-
{
169+
}, {
170+
headers: {
171+
Authorization: `token ${token}`,
172+
},
173+
}
174+
);
175+
176+
await axios.put(
177+
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/package.json`, {
178+
message: 'Update package.json version',
179+
content: contentPackageJson,
180+
branch: branch,
181+
}, {
119182
headers: {
120183
Authorization: `token ${token}`,
121184
},

0 commit comments

Comments
 (0)