-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: decouple static-data from friendsofshopware (#457)
- Loading branch information
Showing
5 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Static Data Deployment | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'static-data/**' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: static-data | ||
cancel-in-progress: false | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '23' | ||
|
||
- name: Fetch current tags | ||
working-directory: static-data | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: node generate.ts | ||
|
||
- name: Delete script | ||
working-directory: static-data | ||
run: rm generate.ts | ||
|
||
- name: Setup Pages | ||
uses: actions/configure-pages@v5 | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: 'static-data' | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package extension | ||
|
||
import ( | ||
"archive/zip" | ||
"bytes" | ||
_ "embed" | ||
"io" | ||
|
||
"github.com/klauspost/compress/zstd" | ||
) | ||
|
||
//go:embed composer-info.zip.zst | ||
var composerInfoFile []byte | ||
|
||
func getComposerInfoFS() (*zip.Reader, error) { | ||
zstReader, err := zstd.NewReader(bytes.NewReader(composerInfoFile)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer zstReader.Close() | ||
|
||
uncompressed, err := io.ReadAll(zstReader) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return zip.NewReader(bytes.NewReader(uncompressed), int64(len(uncompressed))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { writeFileSync } from 'node:fs'; | ||
|
||
async function fetchTagsPage(page: number, headers: Record<string, string>): Promise<Array<{ name: string }>> { | ||
const response = await fetch(`https://api.github.com/repos/shopware/shopware/tags?per_page=100&page=${page}`, { | ||
headers | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
|
||
return await response.json() as Array<{ name: string }>; | ||
} | ||
|
||
async function fetchShopwareTags(): Promise<void> { | ||
const tags: string[] = []; | ||
|
||
try { | ||
const headers: Record<string, string> = { | ||
'User-Agent': 'Shopware-CLI Bot' | ||
}; | ||
|
||
if (process.env.GITHUB_TOKEN) { | ||
headers['Authorization'] = `token ${process.env.GITHUB_TOKEN}`; | ||
} | ||
|
||
let page = 1; | ||
let hasMorePages = true; | ||
|
||
while (hasMorePages) { | ||
const data = await fetchTagsPage(page, headers); | ||
|
||
if (data.length === 0) { | ||
hasMorePages = false; | ||
} else { | ||
for (const tag of data) { | ||
if (tag.name.startsWith('v') && tag.name.indexOf('rc') === -1 && tag.name.indexOf('RC') === -1&& tag.name.indexOf('+ea') === -1 && tag.name.indexOf('+dp') === -1) { | ||
tags.push(tag.name.substring(1)); | ||
} | ||
} | ||
page++; | ||
} | ||
} | ||
|
||
if (!tags.includes('6.7.0.0')) { | ||
tags.unshift('6.7.0.0'); | ||
} | ||
|
||
writeFileSync('versions.json', JSON.stringify(tags, null, 2)); | ||
console.log('Successfully wrote versions.json'); | ||
|
||
} catch (error) { | ||
console.error('Error:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// Execute the function | ||
fetchShopwareTags(); |