-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI for building and releasing index files
- Loading branch information
1 parent
1908395
commit ab888a8
Showing
4 changed files
with
133 additions
and
0 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,32 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Check for proper number of command line args. | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 path_to_json.xz new_url" | ||
exit 1 | ||
fi | ||
|
||
# Assign command line args to variables | ||
input_file="$1" | ||
new_url="$2" | ||
temp_json=$(mktemp -t modified-json-XXXXX) | ||
|
||
# Decompress the .xz file into a temporary JSON file | ||
xz -d -k -c "${input_file}" > "${temp_json}" | ||
|
||
# Check if jq is installed | ||
if ! command -v jq &> /dev/null | ||
then | ||
echo "jq could not be found, please install jq to use this script." | ||
exit 1 | ||
fi | ||
|
||
# Update the URL field using jq | ||
jq --arg new_url "$new_url" '.entries[0].url = $new_url' "${temp_json}" > "${temp_json}.tmp" && mv "${temp_json}.tmp" "${temp_json}" | ||
|
||
# Compress the modified JSON file back into the .xz format | ||
xz -z -c "${temp_json}" > "${input_file}" | ||
|
||
echo "The url field has been updated to $new_url and the file ${input_file} is modified" |
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,89 @@ | ||
name: Index project and release shared indexes | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
project-name: | ||
description: 'The name of the project to index and release' | ||
required: true | ||
type: string | ||
|
||
env: | ||
ARTIFACT_NAME: "index-assets" | ||
DOWNLOADED_ARTIFACTS: "indexing-results" | ||
|
||
jobs: | ||
indexing: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
|
||
- name: Generate full-project if requested | ||
if: ${{ inputs.project-name == 'full-project' }} | ||
run: sbt 'runMain com.virtuslab.example.generator.FullProjectGenerator' | ||
|
||
- name: Install IJ | ||
run: sudo snap install intellij-idea-community --channel=2023.3/stable --classic | ||
- name: IJ install Shared Indexes plugin | ||
run: intellij-idea-community installPlugins intellij.indexing.shared | ||
|
||
- name: Build shared indexes | ||
run: | | ||
mkdir -p workspace/project-indexes | ||
intellij-idea-community dump-shared-index project --project-id=${{ inputs.project-name }} --project-dir=examples/${{ inputs.project-name }} --output=workspace/project-indexes | ||
- name: Build cdn structure | ||
run: sbt 'runMain com.virtuslab.shared_indexes.Main project' | ||
|
||
- name: Check indexes | ||
run: ls -lh workspace/cdn | ||
|
||
- name: Archive index artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
path: workspace/cdn | ||
if-no-files-found: error | ||
|
||
release: | ||
needs: indexing | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set RELEASE_URL | ||
run: echo "RELEASE_URL=https://github.com/${GITHUB_REPOSITORY}/releases/download/${{ inputs.project-name }}" >> $GITHUB_ENV | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
path: ${{ env.DOWNLOADED_ARTIFACTS }} | ||
|
||
- name: Swap data url in index.json.xz | ||
run: | | ||
PATH_TO_INDEX_FILE=(${{ env.DOWNLOADED_ARTIFACTS }}/data/project/${{ inputs.project-name }}/*.ijx.xz) | ||
.github/scripts/swap-index-url.sh "${{ env.DOWNLOADED_ARTIFACTS }}/project/${{ inputs.project-name }}/index.json.xz" "${{ env.RELEASE_URL }}/$(basename "$PATH_TO_INDEX_FILE")" | ||
- name: Create Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ inputs.project-name }} | ||
draft: true | ||
prerelease: false | ||
fail_on_unmatched_files: true | ||
files: | | ||
${{ env.DOWNLOADED_ARTIFACTS }}/project/list.json.xz | ||
${{ env.DOWNLOADED_ARTIFACTS }}/project/${{ inputs.project-name }}/index.json.xz | ||
${{ env.DOWNLOADED_ARTIFACTS }}/data/project/${{ inputs.project-name }}/*.ijx.xz | ||
${{ env.DOWNLOADED_ARTIFACTS }}/data/project/${{ inputs.project-name }}/*.metadata.json | ||
${{ env.DOWNLOADED_ARTIFACTS }}/data/project/${{ inputs.project-name }}/*.sha256 |
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,6 @@ | ||
sharedIndex: | ||
project: | ||
- url: https://github.com/VirtuslabRnD/ij-indexing-tools/releases/download/1.0.0-multi-jar/ | ||
consents: | ||
- kind: project | ||
decision: allowed |
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,6 @@ | ||
sharedIndex: | ||
project: | ||
- url: https://github.com/VirtuslabRnD/ij-indexing-tools/releases/download/1.0.0-multi-jdk/ | ||
consents: | ||
- kind: project | ||
decision: allowed |