Bump version from 0.1.0 to 0.1.1 #2
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: Release | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| check-release: | |
| name: Check release | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| needs_github_release: ${{ steps.check.outputs.needs_github_release }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: check | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| LOCAL=$(node -p "require('./package.json').version") | |
| echo "Local version: $LOCAL" | |
| NPM=$(npm view @supermemory/preprint version 2>/dev/null || echo "0.0.0") | |
| echo "npm version: $NPM" | |
| if [ "$LOCAL" != "$NPM" ]; then | |
| echo "should_release=true" >> "$GITHUB_OUTPUT" | |
| echo "needs_github_release=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "should_release=false" >> "$GITHUB_OUTPUT" | |
| TAG="v$LOCAL" | |
| if gh release view "$TAG" &>/dev/null; then | |
| echo "needs_github_release=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "needs_github_release=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| fi | |
| echo "version=$LOCAL" >> "$GITHUB_OUTPUT" | |
| build: | |
| name: Build ${{ matrix.name }} | |
| needs: check-release | |
| if: needs.check-release.outputs.should_release == 'true' || needs.check-release.outputs.needs_github_release == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { name: darwin-arm64, os: macos-latest, target: aarch64-apple-darwin, use_zigbuild: false, ext: "" } | |
| - { name: darwin-x64, os: macos-latest, target: x86_64-apple-darwin, use_zigbuild: false, ext: "" } | |
| - { name: linux-x64, os: ubuntu-latest, target: x86_64-unknown-linux-gnu, use_zigbuild: true, ext: "" } | |
| - { name: linux-arm64, os: ubuntu-latest, target: aarch64-unknown-linux-gnu, use_zigbuild: true, ext: "" } | |
| - { name: linux-musl-x64, os: ubuntu-latest, target: x86_64-unknown-linux-musl, use_zigbuild: true, ext: "" } | |
| - { name: linux-musl-arm64, os: ubuntu-latest, target: aarch64-unknown-linux-musl, use_zigbuild: true, ext: "" } | |
| - { name: win32-x64, os: ubuntu-latest, target: x86_64-pc-windows-gnu, use_zigbuild: false, ext: ".exe" } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Install mingw (windows cross) | |
| if: matrix.target == 'x86_64-pc-windows-gnu' | |
| run: sudo apt-get update && sudo apt-get install -y mingw-w64 | |
| - name: Install zigbuild | |
| if: matrix.use_zigbuild | |
| run: | | |
| pip3 install ziglang | |
| cargo install cargo-zigbuild | |
| - name: Build (zigbuild) | |
| if: matrix.use_zigbuild | |
| run: cargo zigbuild --release --no-default-features --target ${{ matrix.target }} | |
| - name: Build (cargo) | |
| if: '!matrix.use_zigbuild' | |
| run: cargo build --release --no-default-features --target ${{ matrix.target }} | |
| - name: Stage artifacts | |
| shell: bash | |
| run: | | |
| mkdir -p artifacts | |
| cp "target/${{ matrix.target }}/release/preprint${{ matrix.ext }}" "artifacts/preprint-${{ matrix.name }}${{ matrix.ext }}" | |
| cp "agent-browser/agent-browser-${{ matrix.name }}${{ matrix.ext }}" "artifacts/agent-browser-${{ matrix.name }}${{ matrix.ext }}" | |
| chmod +x artifacts/* 2>/dev/null || true | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: preprint-${{ matrix.name }} | |
| path: artifacts/* | |
| if-no-files-found: error | |
| publish: | |
| name: Publish npm | |
| needs: [check-release, build] | |
| if: needs.check-release.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| environment: Release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: staged/ | |
| - name: Move binaries into bin/ | |
| run: | | |
| mkdir -p bin | |
| find staged -type f -name 'preprint-*' -exec mv {} bin/ \; | |
| find staged -type f -name 'agent-browser-*' -exec mv {} bin/ \; | |
| rm -rf staged | |
| chmod +x bin/preprint-* bin/agent-browser-* 2>/dev/null || true | |
| ls -la bin/ | |
| - name: Verify all 14 binaries present | |
| run: | | |
| EXPECTED=( | |
| preprint-darwin-arm64 | |
| preprint-darwin-x64 | |
| preprint-linux-x64 | |
| preprint-linux-arm64 | |
| preprint-linux-musl-x64 | |
| preprint-linux-musl-arm64 | |
| preprint-win32-x64.exe | |
| agent-browser-darwin-arm64 | |
| agent-browser-darwin-x64 | |
| agent-browser-linux-x64 | |
| agent-browser-linux-arm64 | |
| agent-browser-linux-musl-x64 | |
| agent-browser-linux-musl-arm64 | |
| agent-browser-win32-x64.exe | |
| ) | |
| ERRORS=0 | |
| for f in "${EXPECTED[@]}"; do | |
| if [ ! -f "bin/$f" ]; then | |
| echo "missing bin/$f" | |
| ERRORS=$((ERRORS+1)) | |
| else | |
| SIZE=$(stat -c%s "bin/$f") | |
| if [ "$SIZE" -lt 1000000 ]; then | |
| echo "bin/$f too small ($SIZE bytes)" | |
| ERRORS=$((ERRORS+1)) | |
| fi | |
| fi | |
| done | |
| [ "$ERRORS" -eq 0 ] || exit 1 | |
| echo "All 14 binaries present." | |
| - name: Publish | |
| run: npm publish --provenance --access public | |
| github-release: | |
| name: GitHub release | |
| needs: [check-release, build] | |
| if: always() && needs.build.result == 'success' && needs.check-release.outputs.needs_github_release == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: staged/ | |
| - name: Collect binaries | |
| run: | | |
| mkdir -p release | |
| find staged -type f \( -name 'preprint-*' -o -name 'agent-browser-*' \) -exec mv {} release/ \; | |
| chmod +x release/* 2>/dev/null || true | |
| ls -la release/ | |
| - name: Extract changelog entry | |
| run: | | |
| awk '/<!-- release:start -->/{f=1; next} /<!-- release:end -->/{f=0} f' CHANGELOG.md > /tmp/notes.md | |
| [ -s /tmp/notes.md ] || { echo "no release notes between markers"; exit 1; } | |
| - name: Create or update release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ needs.check-release.outputs.version }}" | |
| if gh release view "$TAG" &>/dev/null; then | |
| gh release upload "$TAG" release/* --clobber | |
| else | |
| gh release create "$TAG" --title "$TAG" --notes-file /tmp/notes.md release/* | |
| fi |