| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| name: packaging |
| |
| on: |
| pull_request: |
| branches: |
| - main |
| paths: |
| - "CMakeLists.txt" |
| - "src/nanoarrow/**" |
| - "r/**" |
| - "dev/release/**" |
| - ".github/workflows/packaging.yaml" |
| |
| push: |
| # Automatically build on RC tags |
| branches-ignore: |
| - '**' |
| tags: |
| - 'apache-arrow-nanoarrow-*-rc*' |
| |
| concurrency: |
| group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }} |
| cancel-in-progress: true |
| |
| jobs: |
| source: |
| name: Source |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v3 |
| with: |
| fetch-depth: 0 |
| |
| - name: Prepare version |
| shell: bash |
| run: | |
| if [ "${GITHUB_REF_TYPE}" = "tag" ]; then |
| VERSION=${GITHUB_REF_NAME#apache-arrow-nanoarrow-} |
| VERSION=${VERSION%-rc*} |
| else |
| VERSION=$(grep 'set(NANOARROW_VERSION' CMakeLists.txt | \ |
| grep -E -o '[0-9]+\.[0-9]+\.[0-9]+') |
| description=$(git describe \ |
| --always \ |
| --dirty \ |
| --long \ |
| --match "apache-arrow-nanoarrow-[0-9]*.*" \ |
| --tags) |
| case "${description}" in |
| # apache-arrow-nanoarrow-0.1.0-10-1234567-dirty |
| apache-arrow-nanoarrow-*) |
| # 10-1234567-dirty |
| distance="${description#apache-arrow-nanoarrow-*.*.*-}" |
| # 10-1234567 |
| distance="${distance%-dirty}" |
| # 10 |
| distance="${distance%-*}" |
| ;; |
| *) |
| distance=$(git log --format=oneline | wc -l) |
| ;; |
| esac |
| VERSION="${VERSION}.dev${distance}" |
| fi |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV |
| |
| - name: Create archive |
| shell: bash |
| run: | |
| dev/release/source_build.sh \ |
| apache-arrow-nanoarrow-${VERSION} \ |
| $(git log -n 1 --format=%h) |
| |
| - uses: actions/upload-artifact@v3 |
| with: |
| name: source |
| retention-days: 7 |
| path: | |
| apache-arrow-nanoarrow-${{ env.VERSION }}.tar.gz |
| |
| docs: |
| name: "Documentation" |
| runs-on: ubuntu-latest |
| needs: |
| - source |
| steps: |
| - uses: actions/download-artifact@v3 |
| with: |
| name: source |
| |
| - name: Extract source archive |
| run: | |
| source_archive=$(echo apache-arrow-nanoarrow-*.tar.gz) |
| VERSION=${source_archive#apache-arrow-nanoarrow-} |
| VERSION=${VERSION%.tar.gz} |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV |
| tar xf apache-arrow-nanoarrow-${VERSION}.tar.gz |
| mv apache-arrow-nanoarrow-${VERSION} nanoarrow |
| |
| - name: Show inputs |
| shell: bash |
| run: | |
| echo "upload_artifacts: ${{ inputs.upload_artifacts }}" |
| echo "schedule: ${{ github.event.schedule }}" |
| echo "ref: ${{ github.ref }}" |
| |
| - name: Build documentation |
| run: | |
| pushd nanoarrow |
| docker compose run --rm docs |
| popd |
| |
| - name: Compress docs |
| shell: bash |
| run: | |
| pushd nanoarrow |
| tar --transform "s|docs/_build/html|nanoarrow-docs|" -czf ../docs.tgz docs/_build/html |
| popd |
| |
| - name: Archive docs |
| uses: actions/upload-artifact@v3 |
| with: |
| name: docs |
| retention-days: 2 |
| path: | |
| docs.tgz |
| |
| r: |
| name: "R" |
| runs-on: ubuntu-latest |
| needs: |
| - source |
| steps: |
| - uses: actions/download-artifact@v3 |
| with: |
| name: source |
| |
| - name: Extract source archive |
| run: | |
| source_archive=$(echo apache-arrow-nanoarrow-*.tar.gz) |
| VERSION=${source_archive#apache-arrow-nanoarrow-} |
| VERSION=${VERSION%.tar.gz} |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV |
| tar xf apache-arrow-nanoarrow-${VERSION}.tar.gz |
| mv apache-arrow-nanoarrow-${VERSION} nanoarrow |
| |
| - name: Show inputs |
| shell: bash |
| run: | |
| echo "upload_artifacts: ${{ inputs.upload_artifacts }}" |
| echo "schedule: ${{ github.event.schedule }}" |
| echo "ref: ${{ github.ref }}" |
| |
| - uses: r-lib/actions/setup-pandoc@v2 |
| - uses: r-lib/actions/setup-r@v2 |
| with: |
| use-public-rspm: true |
| |
| - uses: r-lib/actions/setup-r-dependencies@v2 |
| with: |
| extra-packages: any::pkgbuild, any::desc |
| needs: build |
| working-directory: nanoarrow/r |
| |
| - name: Build R Source Package |
| shell: bash |
| run : | |
| # Install the package from source. This will generate and copy the |
| # latest nanoarrow C bundle as well. |
| R CMD INSTALL nanoarrow/r --preclean |
| |
| # Make a directory just for the output tarball to simplify the |
| # upload-artifact step. |
| mkdir nanoarrow-r-pkg && cd nanoarrow-r-pkg |
| R CMD build ../nanoarrow/r |
| |
| - uses: actions/upload-artifact@v3 |
| with: |
| name: r-source |
| retention-days: 7 |
| path: | |
| nanoarrow-r-pkg/*.tar.gz |
| |
| release: |
| name: "Create release" |
| runs-on: ubuntu-latest |
| if: startsWith(github.ref, 'refs/tags/') |
| needs: |
| - docs |
| - source |
| - r |
| |
| steps: |
| - name: Get All Artifacts |
| uses: actions/download-artifact@v3 |
| with: |
| path: release-artifacts |
| - name: Release |
| shell: bash |
| run: | |
| RELEASE_TAG=${GITHUB_REF#refs/*/} |
| # Deduplicate artifacts built in different jobs with same tag |
| mkdir -p upload-staging |
| find ./release-artifacts/ \ |
| '(' \ |
| -name docs.tgz -or \ |
| -name 'nanoarrow_*.tar.gz' -or \ |
| -name 'apache-arrow-nanoarrow-*.tar.gz' \ |
| ')' \ |
| -exec mv '{}' upload-staging \; |
| UPLOAD=$(find upload-staging -type f | sort | uniq) |
| echo "Uploading files:" |
| echo ${UPLOAD} |
| gh release create "${RELEASE_TAG}" \ |
| --repo ${{ github.repository }} \ |
| --prerelease \ |
| --title "nanoarrow ${RELEASE_TAG}" \ |
| ${UPLOAD} |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |