diff --git a/.github/scripts/swap-index-url.sh b/.github/scripts/swap-index-url.sh new file mode 100755 index 0000000..415348e --- /dev/null +++ b/.github/scripts/swap-index-url.sh @@ -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" \ No newline at end of file diff --git a/.github/workflows/install-index-release.yml b/.github/workflows/install-index-release.yml new file mode 100644 index 0000000..b0dcb1f --- /dev/null +++ b/.github/workflows/install-index-release.yml @@ -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 diff --git a/examples/multi-jar/intellij.yaml b/examples/multi-jar/intellij.yaml new file mode 100644 index 0000000..54e2211 --- /dev/null +++ b/examples/multi-jar/intellij.yaml @@ -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 diff --git a/examples/multi-jdk/intellij.yaml b/examples/multi-jdk/intellij.yaml new file mode 100644 index 0000000..4c61708 --- /dev/null +++ b/examples/multi-jdk/intellij.yaml @@ -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