ci package: use environment variable #974
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: | |
branches: | |
- "*" | |
tags: | |
- "*" | |
pull_request: | |
branches: | |
- "*" | |
schedule: | |
- cron: | | |
0 0 * * * | |
jobs: | |
build: | |
name: Build | |
strategy: | |
fail-fast: false | |
matrix: | |
id: | |
- debian-bullseye-amd64 | |
- debian-bullseye-arm64 | |
- debian-bookworm-amd64 | |
- debian-bookworm-arm64 | |
- centos-7 | |
- amazon-linux-2 | |
- almalinux-8 | |
- almalinux-8-aarch64 | |
- almalinux-9 | |
- almalinux-9-aarch64 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Prepare environment variables | |
run: | | |
set -eux | |
id=${{ matrix.id }} | |
case ${id} in | |
debian-*) | |
echo "APT_TARGETS=${id%-amd64}" >> ${GITHUB_ENV} | |
echo "TASK_NAMESPACE=apt" >> ${GITHUB_ENV} | |
;; | |
*) | |
echo "YUM_TARGETS=${id}" >> ${GITHUB_ENV} | |
echo "TASK_NAMESPACE=yum" >> ${GITHUB_ENV} | |
;; | |
esac | |
- uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
path: groonga | |
repository: groonga/groonga | |
submodules: recursive | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt -y -V install software-properties-common | |
sudo add-apt-repository -y universe | |
sudo add-apt-repository -y ppa:groonga/ppa | |
sudo apt update | |
sudo apt -V install \ | |
devscripts \ | |
libgroonga-dev \ | |
qemu-user-static \ | |
ruby | |
- name: Generate configure | |
run: | | |
./autogen.sh | |
- name: Configure for archive | |
run: | | |
./configure | |
- name: Build archive | |
run: | | |
make dist | |
- name: Build with docker | |
run: | | |
cd packages | |
rake version:update | |
rake ${TASK_NAMESPACE}:build | |
env: | |
GROONGA_REPOSITORY: ../groonga | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: packages-${{ matrix.id }} | |
path: packages/${{ env.TASK_NAMESPACE }}/repositories/ | |
# Release | |
- name: Create assets | |
if: | | |
github.ref_type == 'tag' | |
run: | | |
tar czf ${{ matrix.id }}.tar.gz packages/${{ matrix.task-namespace }}/repositories/ | |
- name: Ensure creating release | |
if: | | |
github.ref_type == 'tag' | |
id: create-release | |
uses: actions/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor | |
const fs = require("fs"); | |
const path = ".github/workflows/ensure-creating-release.js"; | |
const script = fs.readFileSync(path).toString(); | |
const func = new AsyncFunction("require", "github", "context", script); | |
return await func(require, github, context); | |
- name: Upload to release | |
uses: actions/[email protected] | |
if: | | |
github.ref_type == 'tag' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.result }} | |
asset_path: ${{ matrix.id }}.tar.gz | |
asset_name: ${{ matrix.id }}.tar.gz | |
asset_content_type: application/gzip |