feat: Legacy timestamp grace (#24) #35
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 | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} | |
| env: | |
| COREPACK_ENABLE_STRICT: 0 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - uses: pnpm/action-setup@v4 | |
| name: Install pnpm | |
| with: | |
| run_install: false | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install Dependencies | |
| env: | |
| SKIP_RUST_BUILD: 1 | |
| run: pnpm install --frozen-lockfile | |
| - name: Create Release Pull Request or Publish to npm | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| publish: pnpm ci:release | |
| commit: "chore: version packages" | |
| title: "chore: version packages" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Check object | |
| run: | | |
| cat << OBJECT | |
| ${{ toJson(steps.changesets.outputs) }} | |
| OBJECT | |
| release-binaries: | |
| needs: release | |
| if: needs.release.outputs.published == 'true' | |
| name: Build binaries for ${{matrix.target}} | |
| runs-on: ${{matrix.runner}} | |
| env: | |
| PUBLISHED_VERSION: ${{ fromJson(needs.release.outputs.publishedPackages)[0].version }} | |
| COREPACK_ENABLE_STRICT: 0 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: aarch64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| - target: x86_64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| - target: aarch64-apple-darwin | |
| runner: macos-14 | |
| - target: x86_64-apple-darwin | |
| runner: macos-13 | |
| - target: x86_64-pc-windows-msvc | |
| runner: windows-latest | |
| steps: | |
| - name: Show published packages | |
| run: | | |
| echo '${{ needs.release.outputs.publishedPackages }}' | |
| - uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - name: Install system deps (aarch64-unknown-linux-gnu) | |
| if: ${{matrix.target == 'aarch64-unknown-linux-gnu'}} | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: llvm-tools-preview | |
| toolchain: 1.88.0 | |
| target: ${{matrix.target}} | |
| - uses: pnpm/action-setup@v4 | |
| name: Install pnpm | |
| with: | |
| run_install: false | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Cache Rust dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: ${{matrix.target}} | |
| - name: Install Node.js dependencies | |
| env: | |
| SKIP_RUST_BUILD: 1 | |
| run: pnpm install --frozen-lockfile | |
| - name: Build library for aarch64-unknown-linux-gnu | |
| if: ${{matrix.target == 'aarch64-unknown-linux-gnu'}} | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc | |
| CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++ | |
| run: | | |
| mkdir -p generated/${{matrix.target}} | |
| pnpm run build:rust --target=${{matrix.target}} | |
| cp index.node generated | |
| - name: Build library | |
| id: build-library | |
| if: ${{!contains(fromJSON('["aarch64-unknown-linux-gnu"]'), matrix.target)}} | |
| run: | | |
| mkdir -p generated/${{matrix.target}} | |
| pnpm run build:rust --target=${{matrix.target}} | |
| cp index.node generated | |
| - name: Package artifact | |
| id: package-artifact | |
| # This needs to be set so that this works on a Windows runner | |
| shell: bash | |
| env: | |
| ARCHIVE_FILENAME: c2pa-node_${{matrix.target}}-v${{ env.PUBLISHED_VERSION || '-dev' }}.zip | |
| run: | | |
| cd generated | |
| 7z a -tzip "${{ env.ARCHIVE_FILENAME }}" index.node | |
| echo "archive=${{ env.ARCHIVE_FILENAME }}" >> "$GITHUB_OUTPUT" | |
| - name: Upload artifact (development only) | |
| id: upload-artifact | |
| uses: actions/upload-artifact@v4 | |
| if: needs.release.outputs.published != 'true' | |
| with: | |
| name: ${{ steps.package-artifact.outputs.archive }} | |
| path: generated/${{ steps.package-artifact.outputs.archive }} | |
| retention-days: 3 | |
| - id: get-release-id | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "id=$(curl -s -L \ | |
| -H 'Accept: application/vnd.github+json' \ | |
| -H 'Authorization: Bearer ${{ env.GITHUB_TOKEN }}' \ | |
| -H 'X-GitHub-Api-Version: 2022-11-28' \ | |
| https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.PUBLISHED_VERSION }} | jq '.id')" >> "$GITHUB_OUTPUT" | |
| - name: Upload release asset | |
| if: needs.release.outputs.published == 'true' | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| curl -L \ | |
| -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| -H "Content-Type: application/zip" \ | |
| "https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.get-release-id.outputs.id }}/assets?name=${{ steps.package-artifact.outputs.archive }}" \ | |
| --data-binary "@generated/${{ steps.package-artifact.outputs.archive }}" |