Package #1290
This file contains 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: Package | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: | | |
0 0 * * * | |
jobs: | |
source: | |
name: Source | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build archive | |
run: | | |
rake dist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release-source | |
path: | | |
groonga-normalizer-mysql-*.tar.gz | |
groonga-normalizer-mysql-*.zip | |
build: | |
name: Build | |
needs: source | |
strategy: | |
fail-fast: false | |
matrix: | |
id: | |
- debian-bookworm-amd64 | |
- debian-bookworm-arm64 | |
- almalinux-8-x86_64 | |
- almalinux-8-aarch64 | |
- almalinux-9-x86_64 | |
- almalinux-9-aarch64 | |
- amazon-linux-2023-x86_64 | |
# Groonga doesn't provide the package for | |
# amazon-linux-2023-aarch64 yet. | |
# - amazon-linux-2023-aarch64 | |
runs-on: ubuntu-latest | |
env: | |
APACHE_ARROW_REPOSITORY: ${{ github.workspace }}/apache-arrow | |
steps: | |
- name: Prepare environment variables | |
run: | | |
set -eux | |
id=${{ matrix.id }} | |
os_version=${id%-*} | |
os=${os_version%-*} | |
# amazon-linux -> amazonlinux | |
docker_os=${os/-/} | |
version=${os_version##*-} | |
architecture=${id##*-} | |
if [ ${os} = "debian" ] ;then | |
echo "APT_TARGETS=${id%-amd64}" >> ${GITHUB_ENV} | |
echo "TASK_NAMESPACE=apt" >> ${GITHUB_ENV} | |
else | |
echo "YUM_TARGETS=${id%-x86_64}" >> ${GITHUB_ENV} | |
echo "TASK_NAMESPACE=yum" >> ${GITHUB_ENV} | |
fi | |
TEST_DOCKER_IMAGE="${docker_os}:${version}" | |
if [ "${architecture}" = "arm64" ] || \ | |
[ "${architecture}" = "aarch64" ]; then | |
TEST_DOCKER_IMAGE="arm64v8/${TEST_DOCKER_IMAGE}" | |
fi | |
echo "TEST_DOCKER_IMAGE=${TEST_DOCKER_IMAGE}" >> ${GITHUB_ENV} | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt -V install \ | |
devscripts \ | |
qemu-user-static \ | |
ruby | |
- uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
path: groonga | |
repository: groonga/groonga | |
submodules: recursive | |
- uses: actions/checkout@v4 | |
with: | |
path: apache-arrow | |
repository: apache/arrow | |
- uses: actions/download-artifact@v4 | |
with: | |
name: release-source | |
- name: Update version | |
if: | | |
github.ref_type != 'tag' | |
run: | | |
cd packages | |
rake version:update | |
env: | |
GROONGA_REPOSITORY: ../groonga | |
- name: Login to GitHub Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build with docker | |
run: | | |
cd packages | |
rake docker:pull || : | |
rake ${TASK_NAMESPACE}:build | |
env: | |
GROONGA_REPOSITORY: ../groonga | |
- name: Push the built Docker image | |
continue-on-error: true | |
run: | | |
cd packages | |
rake docker:push | |
env: | |
GROONGA_REPOSITORY: ../groonga | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: packages-${{ matrix.id }} | |
path: packages/${{ env.TASK_NAMESPACE }}/repositories/ | |
- name: Test | |
run: | | |
case "${TEST_DOCKER_IMAGE}" in | |
arm64v8/*) | |
platform=linux/arm64 | |
;; | |
*) | |
platform=linux/amd64 | |
;; | |
esac | |
docker run \ | |
--platform ${platform} \ | |
--rm \ | |
--volume ${PWD}:/host:ro \ | |
${TEST_DOCKER_IMAGE} \ | |
/host/packages/${TASK_NAMESPACE}/test.sh | |
prepare-for-release: | |
name: Prepare for release | |
needs: build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: packages | |
pattern: packages-* | |
- name: Group by distribution and version | |
run: | | |
set -x | |
for packages_path in packages/*; do | |
# packages/packages-debian-bookworm-amd64 -> | |
# debian-bookworm | |
os=$(echo ${packages_path} | \ | |
grep -E -o '(almalinux|amazon-linux|debian)-[^-]+') | |
mkdir -p release/${os}/ | |
# packages/packages-debian-bookworm-amd64/debian/bookworm/source/ -> | |
# release/debian-bookworm/debian/bookworm/source/ | |
rsync -a ${packages_path}/ release/${os}/ | |
done | |
for release_os_path in release/*; do | |
# release/debian-bookworm -> | |
# debian-bookworm | |
os=$(basename ${release_os_path}) | |
# release/debian-bookworm/debian/... -> | |
# debian-bookworm/debian/... | |
tar czf ${os}.tar.gz -C $(dirname ${release_os_path}) ${os} | |
done | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release-packages | |
path: "*.tar.gz" | |
release: | |
if: | | |
github.ref_type == 'tag' | |
name: Release | |
needs: prepare-for-release | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: release-artifacts | |
pattern: release-* | |
merge-multiple: true | |
- name: Upload | |
run: | | |
ruby \ | |
-e 'print("## groonga-normalizer-mysql "); \ | |
puts(ARGF.read.split(/^## /)[1].strip)' \ | |
doc/text/news.md > release-note.md | |
version=${GITHUB_REF_NAME#v} | |
title="$(head -n1 release-note.md | sed -e 's/^## //')" | |
tail -n +2 release-note.md > release-note-without-version.md | |
gh release create ${GITHUB_REF_NAME} \ | |
--discussion-category Announcements \ | |
--notes-file release-note-without-version.md \ | |
--title "${title}" \ | |
release-artifacts/* | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |