Package #500
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
# Copyright (C) 2023 Sutou Kouhei <[email protected]> | |
# | |
# This library is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU Lesser General Public | |
# License as published by the Free Software Foundation; either | |
# version 2.1 of the License, or (at your option) any later version. | |
# | |
# This library is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
# Lesser General Public License for more details. | |
# | |
# You should have received a copy of the GNU Lesser General Public | |
# License along with this library; if not, write to the Free Software | |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
name: Package | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: | | |
0 0 * * * | |
concurrency: | |
group: ${{ github.head_ref || github.sha }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
source: | |
if: >- | |
github.event_name != 'schedule' || | |
(github.event_name == 'schedule' && | |
github.repository_owner == 'groonga') | |
name: Source | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build archive | |
run: | | |
rake dist | |
# Artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: source | |
path: | | |
groonga-nginx-*.tar.gz | |
# Release | |
- name: Upload to release | |
if: | | |
startsWith(github.ref, 'refs/tags/') | |
run: | | |
ruby \ | |
-e 'print("## groonga-nginx "); \ | |
puts(ARGF.read.split(/^## /)[1]. \ | |
gsub(/ {.+?}/, ""). \ | |
gsub(/\[(.+?)\]\[.+?\]/) {$1})' \ | |
NEWS.md > release-note.md | |
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}" \ | |
groonga-nginx-*.tar.gz | |
env: | |
GH_TOKEN: ${{ github.token }} | |
build: | |
name: Build | |
needs: source | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- id: debian-bookworm-amd64 | |
task-namespace: apt | |
test-image: "images:debian/12" | |
# We can't use Incus for different architecture. | |
# - id: debian-bookworm-arm64 | |
# task-namespace: apt | |
# test-image: "images:debian/12/arm64" | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
env: | |
APACHE_ARROW_REPOSITORY: ${{ github.workspace }}/apache-arrow | |
GROONGA_REPOSITORY: ${{ github.workspace }}/groonga | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
path: apache-arrow | |
repository: apache/arrow | |
- uses: actions/checkout@v4 | |
with: | |
repository: groonga/groonga | |
path: groonga | |
submodules: recursive | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y -V \ | |
devscripts \ | |
qemu-user-static \ | |
ruby | |
- uses: actions/download-artifact@v4 | |
with: | |
name: source | |
- name: Update version | |
if: | | |
!startsWith(github.ref, 'refs/tags/') | |
run: | | |
cd packages | |
rake version:update RELEASE_DATE=$(date +%Y-%m-%d) | |
- name: Login to GitHub Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cache ccache | |
uses: actions/cache@v4 | |
with: | |
path: packages/${{ matrix.task-namespace }}/build/${{ matrix.id }}/ccache | |
key: package-${{ matrix.id }}-ccache-${{ hashFiles('*.c') }} | |
restore-keys: package-${{ matrix.id }}-ccache- | |
- name: Prepare target | |
run: | | |
target=$(echo ${{ matrix.id }} | sed -e 's/-amd64$//g') | |
echo "APT_TARGETS=${target}" >> $GITHUB_ENV | |
echo "YUM_TARGETS=${target}" >> $GITHUB_ENV | |
- name: Build with docker | |
run: | | |
cd packages | |
rake docker:pull || : | |
rake ${{ matrix.task-namespace }}:build BUILD_DIR=build | |
- name: Push the built Docker image | |
continue-on-error: true | |
run: | | |
cd packages | |
rake docker:push | |
# Artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: packages-${{ matrix.id }} | |
path: packages/${{ matrix.task-namespace }}/repositories/ | |
# Release | |
- name: Create assets | |
if: | | |
startsWith(github.ref, 'refs/tags/') | |
run: | | |
tar czf ${{ matrix.id }}.tar.gz packages/${{ matrix.task-namespace }}/repositories/ | |
- name: Upload to release | |
if: | | |
startsWith(github.ref, 'refs/tags/') | |
run: | | |
gh release upload ${GITHUB_REF_NAME} \ | |
${{ matrix.id }}.tar.gz | |
env: | |
GH_TOKEN: ${{ github.token }} | |
# Test | |
- name: Install test dependencies | |
run: | | |
# We can use the official Ubuntu APT repository when | |
# ubuntu-latest is Ubuntu 24.04. | |
sudo curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc | |
cat <<SOURCES | sudo tee /etc/apt/sources.list.d/zabbly-incus-stable.sources | |
Enabled: yes | |
Types: deb | |
URIs: https://pkgs.zabbly.com/incus/stable | |
Suites: $(. /etc/os-release && echo ${VERSION_CODENAME}) | |
Components: main | |
Architectures: $(dpkg --print-architecture) | |
Signed-By: /etc/apt/keyrings/zabbly.asc | |
SOURCES | |
sudo apt update | |
sudo apt install -y -V incus | |
- name: Allow egress network traffic flows for Incus | |
# https://linuxcontainers.org/incus/docs/main/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-incus-and-docker | |
run: | | |
sudo iptables -I DOCKER-USER -i incusbr0 -j ACCEPT | |
sudo iptables -I DOCKER-USER -o incusbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT | |
- name: Test | |
run: | | |
sudo incus admin init --auto | |
sudo incus launch ${{ matrix.test-image }} target | |
sudo incus config device add target host disk source=$PWD path=/host | |
sudo incus exec target -- adduser --uid 10000 groonga-nginx | |
sudo incus exec target -- \ | |
sh -c "echo 'groonga-nginx ALL=(ALL:ALL) NOPASSWD:ALL' | \ | |
EDITOR='tee -a' visudo -f /etc/sudoers.d/groonga-nginx-nopasswd" | |
sudo incus exec target \ | |
--cwd /home/groonga-nginx \ | |
--user 10000 \ | |
--group 10000 \ | |
-- \ | |
/host/packages/${{ matrix.task-namespace }}/test.sh | |
sudo incus stop target | |
sudo incus delete target |