Create jpv3 README (#270) #15
This file contains hidden or 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
| name: Maven CLI Release | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| env: | |
| TARGET_VERSION: 25 | |
| JDK_VERSION: 25 | |
| permissions: | |
| contents: read | |
| jobs: | |
| generate-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - id: set-matrix | |
| run: | | |
| MATRIX='{ | |
| "include": [ | |
| { | |
| "os": "ubuntu-latest", | |
| "java": "${{ env.TARGET_VERSION }}", | |
| "graalvm": "${{ env.JDK_VERSION }}", | |
| "suffix": "linux-x64" | |
| }, | |
| { | |
| "os": "macos-latest", | |
| "java": "${{ env.TARGET_VERSION }}", | |
| "graalvm": "${{ env.JDK_VERSION }}", | |
| "suffix": "macos-x64" | |
| }, | |
| { | |
| "os": "windows-latest", | |
| "java": "${{ env.TARGET_VERSION }}", | |
| "graalvm": "${{ env.JDK_VERSION }}", | |
| "suffix": "windows-x64" | |
| } | |
| ] | |
| }' | |
| { | |
| echo 'matrix<<EOF' | |
| echo "$MATRIX" | |
| echo 'EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| build: | |
| name: Maven PR Builder (JDK ${{ matrix.java }}, ${{ matrix.os}}) | |
| needs: generate-matrix | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Install GraalVM | |
| uses: graalvm/setup-graalvm@7a1da54cb7fdef4ea19f6ecdfa9ecf59dc5a48fe # v1.3.6 | |
| with: | |
| java-version: ${{ matrix.graalvm }} | |
| distribution: 'graalvm' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| cache: 'maven' | |
| - name: Build with Maven | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: | | |
| mvn -B -ntp -Pnative -Pjava${{ matrix.java }} verify javadoc:javadoc | |
| - name: Prepare binary artifact | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist | |
| case "${{ runner.os }}" in | |
| Linux) | |
| out_name="jpv3" | |
| ;; | |
| Windows) | |
| out_name="jpv3.exe" | |
| ;; | |
| macOS) | |
| out_name="jpv3" | |
| ;; | |
| esac | |
| cp "target/$out_name" "dist/$out_name" | |
| chmod +x "dist/$out_name" || true | |
| # Only create a Homebrew-friendly tarball for macOS | |
| if [ "${{ runner.os }}" = "macOS" ]; then | |
| tar -C dist -czf "dist/jpv3-${{ matrix.suffix }}.tar.gz" "$out_name" | |
| fi | |
| - name: Upload macOS Homebrew archive | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: ${{ runner.os == 'macOS' }} | |
| with: | |
| name: ${{ matrix.suffix }} | |
| path: dist/*.tar.gz | |
| - name: Upload binary artifact (non-macOS) | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: ${{ runner.os != 'macOS' }} | |
| with: | |
| name: ${{ matrix.suffix }} | |
| path: dist/* | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
| with: | |
| path: dist | |
| - name: Flatten binary artifacts directory | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p bin_out | |
| cp "dist/linux-x64/jpv3" "bin_out/jpv3" | |
| cp "dist/windows-x64/jpv3.exe" "bin_out/jpv3.exe" | |
| cp dist/macos-x64/*.tar.gz "bin_out/" | |
| - name: Compute timestamp | |
| id: ts | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| const pad = num => String(num).padStart(2, '0'); | |
| const date = new Date(); | |
| let timestamp = String(date.getUTCFullYear()); | |
| timestamp += pad(date.getUTCMonth() + 1) + pad(date.getUTCDate()) + '-'; | |
| timestamp += pad(date.getUTCHours()) + pad(date.getUTCMinutes()) + pad(date.getUTCSeconds()) + 'Z'; | |
| core.setOutput('timestamp', timestamp); | |
| - name: Write release metadata (tag) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| tag="jpv3-${{ steps.ts.outputs.timestamp }}" | |
| mkdir -p release_meta | |
| printf "%s" "$tag" > release_meta/tag.txt | |
| - name: Upload release metadata artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: release-meta | |
| path: release_meta/tag.txt | |
| - name: Release binary artifacts | |
| uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # v2.3.3 | |
| with: | |
| tag_name: jpv3-${{ steps.ts.outputs.timestamp }} | |
| name: jpv3-${{ steps.ts.outputs.timestamp }} | |
| files: bin_out/* | |
| prerelease: true | |
| body: | | |
| This is a pre-release of the JPv3 CLI. It is not ready for production use. | |
| Binaries: | |
| - jpv3 (Linux) | |
| - jpv3.exe (Windows) | |
| - jpv3-macos-x64.tar.gz (MacOS) | |
| Homebrew: | |
| There is a tap for Mac users: https://github.com/freelibrary/homebrew-tap | |
| Once you have Homebrew installed locally, run: | |
| - brew tap freelibrary/homebrew-tap | |
| - brew install jpv3 | |
| And you will have the latest version of the CLI installed. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| brew_update: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Download release metadata artifact (tag.txt) | |
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
| with: | |
| name: release-meta | |
| path: release_meta | |
| - name: Download macOS tarball artifact | |
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
| with: | |
| name: macos-x64 | |
| path: dist | |
| - name: Compute sha256 + derive release URL | |
| id: meta | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| tag="$(cat release_meta/tag.txt)" | |
| tarball="$(ls -1 dist/*.tar.gz | head -n 1)" | |
| sha="$(shasum -a 256 "$tarball" | awk '{print $1}')" | |
| asset_name="$(basename "$tarball")" | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| echo "sha256=$sha" >> "$GITHUB_OUTPUT" | |
| echo "asset_name=$asset_name" >> "$GITHUB_OUTPUT" | |
| - name: Check out Homebrew tap repo | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| repository: freelibrary/homebrew-tap | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-tap | |
| - name: Update Formula/jpv3.rb | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| TAP_DIR="homebrew-tap" | |
| FORMULA_PATH="${TAP_DIR}/Formula/jpv3.rb" | |
| tag="${{ steps.meta.outputs.tag }}" | |
| sha="${{ steps.meta.outputs.sha256 }}" | |
| asset="${{ steps.meta.outputs.asset_name }}" | |
| url="https://github.com/${{ github.repository }}/releases/download/${tag}/${asset}" | |
| mkdir -p "${TAP_DIR}/Formula" | |
| cat > "${FORMULA_PATH}" <<EOF | |
| class Jpv3 < Formula | |
| desc "JPv3 command line tool" | |
| homepage "https://github.com/${{ github.repository }}" | |
| version "${tag}" | |
| on_macos do | |
| url "${url}" | |
| sha256 "${sha}" | |
| def install | |
| bin.install "jpv3" | |
| end | |
| end | |
| end | |
| EOF | |
| cd "${TAP_DIR}" | |
| git config user.name "freelibrary-bot" | |
| git config user.email "noreply@github.com" | |
| git add "Formula/jpv3.rb" | |
| git commit -m "jpv3: ${tag}" || echo "No changes to commit" | |
| git push |