diff --git a/.github/workflows/publish_jsr.yml b/.github/workflows/publish_jsr.yml new file mode 100644 index 0000000..11304ac --- /dev/null +++ b/.github/workflows/publish_jsr.yml @@ -0,0 +1,66 @@ +name: 'Publish JSR' +description: | + This workflow serializes the build binary to Base64 and generates a JSON file with meta data about the file. + The file then gets published to JSR (@serial/cpp-bindings-linux). + +on: + workflow_run: + workflows: ['Build Binary'] + types: + - completed + +permissions: + contents: read + id-token: write + +jobs: + publish-jsr: + runs-on: ubuntu-latest + + steps: + - name: 'Checkout repository' + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: 'Setup Deno' + uses: denoland/setup-deno@v2 + with: + deno-version: '2.x' + + - name: 'Download artifact (binary)' + uses: actions/download-artifact@v4 + with: + path: 'artifacts' + name: 'libcpp_bindings_linux_x86_64' + run-id: ${{ github.event.workflow_run.id }} + + - name: 'Download artifact (JSR)' + uses: actions/download-artifact@v4 + with: + path: 'artifacts' + name: 'jsr_json' + run-id: ${{ github.event.workflow_run.id }} + + - name: 'Prepare files for JSR' + run: | + cp ./artifacts/jsr.json ./jsr/jsr.json + cp ./LICENSE ./jsr/LICENSE + + ./jsr/scripts/embed_binary.sh \ + ./artifacts/libcpp_bindings_linux.so \ + ./jsr/bin \ + linux-x86_64 + + - name: 'Publish package to JSR' + if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' + working-directory: jsr + run: | + deno publish --allow-dirty + + - name: 'Publish package to JSR (dry-run)' + if: github.event.workflow_run.event == 'pull_request' + working-directory: jsr + run: | + deno publish --allow-dirty --dry-run +