Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/submit_staging_chrome.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Submit Staging to Chrome Web Store

on:
push:
branches: [ "master" ]
Comment thread
Perplex marked this conversation as resolved.
Comment thread
Perplex marked this conversation as resolved.
workflow_dispatch:
Comment thread
Perplex marked this conversation as resolved.

# Ensure only one staging deployment runs at a time, canceling outdated runs
concurrency:
group: "staging-deploy"
cancel-in-progress: true

jobs:
deploy-staging:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24.x]

steps:
- uses: actions/checkout@v6

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Install Dependencies
run: npm ci

- name: Build Staging Extension
run: npm run build_staging
env:
GITHUB_RUN_NUMBER: ${{ github.run_number }}

- name: Zip Staging Extension
run: |
cd dist
zip -r ../staging-extension.zip .
cd ..

- name: Upload Staging Artifact
uses: actions/upload-artifact@v4
with:
name: staging-extension-${{ github.run_number }}
path: ./staging-extension.zip
retention-days: 180

- name: Cancel Pending Review (If Exists)
continue-on-error: true
run: |
echo "Generating access token..."
ACCESS_TOKEN=$(curl -s -f -X POST "https://oauth2.googleapis.com/token" \
-d "client_id=${{ secrets.OAUTH_CLIENT_ID }}" \
-d "client_secret=${{ secrets.OAUTH_CLIENT_SECRET }}" \
-d "refresh_token=${{ secrets.OAUTH_REFRESH_TOKEN }}" \
-d "grant_type=refresh_token" | jq -r .access_token)

echo "Attempting to cancel any pending staging reviews..."
curl -s -f -X POST \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Length: 0" \
"https://chromewebstore.googleapis.com/v2/publishers/${{ secrets.CWS_PUBLISHER_ID }}/items/${{ secrets.STAGING_CHROME_EXTENSION_ID }}:cancelSubmission"

- name: Publish to Chrome Web Store (Staging)
Comment thread
Perplex marked this conversation as resolved.
uses: browser-actions/release-chrome-extension@v0.2.1
with:
extension-id: ${{ secrets.STAGING_CHROME_EXTENSION_ID }}
extension-path: ./staging-extension.zip
oauth-client-id: ${{ secrets.OAUTH_CLIENT_ID }}
oauth-client-secret: ${{ secrets.OAUTH_CLIENT_SECRET }}
oauth-refresh-token: ${{ secrets.OAUTH_REFRESH_TOKEN }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"scripts": {
"build": "webpack --env mode=prod browser=chrome --config webpack.config.js --stats-error-details",
"build_staging": "webpack --env mode=staging browser=chrome --config webpack.config.js --stats-error-details",
"build_ff": "webpack --env mode=prod browser=firefox --config webpack.config.js --stats-error-details",
"start": "webpack --env mode=development browser=chrome --config webpack.config.js --stats-error-details --watch",
"start_ff": "webpack --env mode=development browser=firefox --config webpack.config.js --stats-error-details --watch",
Expand Down
9 changes: 9 additions & 0 deletions src/environment.staging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const environment = {
csfloat_base_api_url: 'https://csfloat.build/api',
notary: {
tlsn: 'https://notary.csfloat.com',
ws: 'wss://notary.csfloat.com/proxy',
loggingLevel: 'Error',
},
reverse_watch_base_api_url: 'https://reverse.watch/api',
};
50 changes: 43 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ module.exports = (env) => {
test: /environment\.ts$/,
loader: 'file-replace-loader',
options: {
condition: mode === 'development',
replacement: resolve('./src/environment.dev.ts'),
// Activate replacement if mode is development OR staging
condition: mode === 'development' || mode === 'staging',
// Dynamically route to the correct file
replacement:
mode === 'staging'
? resolve('./src/environment.staging.ts')
: resolve('./src/environment.dev.ts'),
},
},
{
Expand All @@ -110,7 +115,7 @@ module.exports = (env) => {
new CopyPlugin({
patterns: [
{from: 'icons', to: 'icons', context: '.'},
{from: 'data', to: 'data', context: '.', globOptions: { ignore: ['bluegem.json'] } },
{from: 'data', to: 'data', context: '.', globOptions: {ignore: ['bluegem.json']}},
{from: 'src/global.css', to: 'src/', context: '.'},
{from: 'src/background_ff.html', to: 'src/', context: '.'},
{from: 'src/steamcommunity_ruleset.json', to: 'src/', context: '.'},
Expand Down Expand Up @@ -149,6 +154,31 @@ module.exports = (env) => {
processed.externally_connectable.matches.push('http://localhost:4200/*');
}

if (mode === 'staging') {
// https://developer.chrome.com/docs/extensions/develop/migrate/publish-mv3#publish-beta
// Grab the run number from the GitHub Action environment, default to 0 for local builds
const runNumber = process.env.GITHUB_RUN_NUMBER || '0';

// Append the run number to the strict version (e.g., 5.14.0.42)
processed.version = `${processed.version}.${runNumber}`;

// Update names
processed.name += ' - STAGING';
processed.short_name += ' (Staging)';
processed.version_name = `${processed.version} (Staging)`;

if (!processed.externally_connectable.matches.includes('*://*.csfloat.build/*')) {
processed.externally_connectable.matches.push('*://*.csfloat.build/*');
}

const versionResource = processed.web_accessible_resources.find((e) =>
e.resources[0].includes('version.txt')
);
if (versionResource && !versionResource.matches.includes('https://csfloat.build/*')) {
versionResource.matches.push('https://csfloat.build/*');
}
}

if (env.browser === 'firefox') {
processed = convertToFirefoxManifest(processed);
}
Expand All @@ -162,17 +192,23 @@ module.exports = (env) => {
transform(raw) {
let processed = JSON.parse(raw.toString());

// Apply the exact same version bump for staging
if (mode === 'staging') {
const runNumber = process.env.GITHUB_RUN_NUMBER || '0';
return `${processed.version}.${runNumber}`;
}

return processed.version;
},
},
],
}),
// Add Gzip compression for bluegem.json
new CompressionPlugin({
filename: "[path][base].gz", // Change extension to .gz
algorithm: "gzip",
filename: '[path][base].gz', // Change extension to .gz
algorithm: 'gzip',
test: /bluegem\.json$/,
deleteOriginalAssets: true,
deleteOriginalAssets: true,
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
Expand All @@ -192,7 +228,7 @@ module.exports = (env) => {
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
}
Comment thread
Perplex marked this conversation as resolved.
},
},
};
};