|
| 1 | +name: Release CLI |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + tag: |
| 6 | + description: Git tag to release assets for. |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + ref: refs/tags/${{ inputs.tag }} |
| 21 | + |
| 22 | + - uses: actions/setup-java@v4 |
| 23 | + with: |
| 24 | + distribution: 'temurin' |
| 25 | + java-version: 8 |
| 26 | + |
| 27 | + - uses: coursier/setup-action@v3 |
| 28 | + with: |
| 29 | + apps: '' |
| 30 | + |
| 31 | + - name: Build standalone launcher |
| 32 | + shell: bash |
| 33 | + env: |
| 34 | + TAG: ${{ inputs.tag }} |
| 35 | + VERSION: ${{ inputs.tag }} |
| 36 | + run: | |
| 37 | + set -euo pipefail |
| 38 | +
|
| 39 | + VERSION=${VERSION#v} |
| 40 | + ARTIFACT="com.sourcegraph:scip-java_2.13:${VERSION}" |
| 41 | +
|
| 42 | + for attempt in {1..10}; do |
| 43 | + if cs resolve "$ARTIFACT" >/dev/null 2>&1; then |
| 44 | + break |
| 45 | + fi |
| 46 | +
|
| 47 | + if [ "$attempt" -eq 10 ]; then |
| 48 | + echo "Artifact $ARTIFACT was not resolvable after 10 attempts" >&2 |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | +
|
| 52 | + sleep 30 |
| 53 | + done |
| 54 | +
|
| 55 | + cs bootstrap \ |
| 56 | + --standalone \ |
| 57 | + --bat=true \ |
| 58 | + -o scip-java \ |
| 59 | + "$ARTIFACT" \ |
| 60 | + --main com.sourcegraph.scip_java.ScipJava |
| 61 | +
|
| 62 | + chmod +x scip-java |
| 63 | + ./scip-java --help >/dev/null |
| 64 | +
|
| 65 | + mv scip-java "scip-java-${TAG}" |
| 66 | + mv scip-java.bat "scip-java-${TAG}.bat" |
| 67 | + shasum -a 256 "scip-java-${TAG}" "scip-java-${TAG}.bat" > "scip-java-${TAG}.sha256" |
| 68 | +
|
| 69 | + - name: Ensure GitHub release exists |
| 70 | + shell: bash |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{ github.token }} |
| 73 | + TAG: ${{ inputs.tag }} |
| 74 | + run: | |
| 75 | + set -euo pipefail |
| 76 | +
|
| 77 | + if ! gh release view "$TAG" >/dev/null 2>&1; then |
| 78 | + gh release create "$TAG" --verify-tag --title "$TAG" --notes "" |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Upload release assets |
| 82 | + shell: bash |
| 83 | + env: |
| 84 | + GH_TOKEN: ${{ github.token }} |
| 85 | + TAG: ${{ inputs.tag }} |
| 86 | + run: | |
| 87 | + set -euo pipefail |
| 88 | +
|
| 89 | + gh release upload "$TAG" \ |
| 90 | + "scip-java-${TAG}" \ |
| 91 | + "scip-java-${TAG}.bat" \ |
| 92 | + "scip-java-${TAG}.sha256" \ |
| 93 | + --clobber |
0 commit comments