ubuntu #378
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: ubuntu | |
on: | |
schedule: | |
- cron: "0 2 * * 2" | |
push: | |
branches: [ main ] | |
tags: [ v* ] | |
paths-ignore: | |
- .github/workflows/macos.yml | |
- .github/workflows/windows.yml | |
- .github/workflows/alpine.yml | |
- .github/workflows/release_tag.yml | |
- .cirrus.* | |
- Makefile.win | |
pull_request: | |
paths-ignore: | |
- .github/workflows/macos.yml | |
- .github/workflows/windows.yml | |
- .github/workflows/alpine.yml | |
- .github/workflows/release_tag.yml | |
- .cirrus.* | |
- Makefile.win | |
workflow_dispatch: | |
concurrency: | |
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}' | |
cancel-in-progress: true | |
jobs: | |
# https://wildwolf.name/github-actions-how-to-avoid-running-the-same-workflow-multiple-times/ | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
head_tag: ${{ steps.check.outputs.head_tag }} | |
foreign_pr: ${{ steps.check.outputs.foreign_pr }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Retrieve tags | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true | |
- name: Set output variables | |
id: check | |
run: | | |
fpr="no" | |
tag="" | |
if [[ "${{ github.ref }}" == refs/heads/* ]]; then | |
tag="$(git tag --points-at HEAD)" | |
elif [[ "${{ github.ref }}" == refs/pull/* ]] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]; then | |
fpr="yes" | |
fi | |
echo "foreign_pr=${fpr}" >> $GITHUB_OUTPUT | |
echo "head_tag=${tag}" >> $GITHUB_OUTPUT | |
build: | |
runs-on: ubuntu-20.04 | |
needs: prepare | |
if: "(github.event_name == 'push' && needs.prepare.outputs.head_tag == '') || github.event_name == 'pull_request' || github.event_name == 'schedule'" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup environment | |
run: cat common.env ubuntu.env >> $GITHUB_ENV | |
# ---------- Start of tebako prerequisites | |
- name: Install packages | |
run: | | |
sudo apt-get -y update | |
sudo apt-get -y install \ | |
binutils-dev libevent-dev acl-dev libfmt-dev libjemalloc-dev \ | |
libdouble-conversion-dev libiberty-dev liblz4-dev liblzma-dev libssl-dev \ | |
libboost-filesystem-dev libboost-program-options-dev libboost-system-dev \ | |
libboost-iostreams-dev libboost-date-time-dev libboost-context-dev \ | |
libboost-regex-dev libboost-thread-dev libbrotli-dev libunwind-dev \ | |
libdwarf-dev libelf-dev libgoogle-glog-dev libffi-dev libgdbm-dev \ | |
libyaml-dev libncurses-dev libreadline-dev libutfcpp-dev | |
- name: Install Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ env.RUBY_VER }} | |
bundler: ${{ env.BUNDLER_VER }} | |
- name: Tebako setup cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.TEBAKO_DIR }}/${{ env.DEPS }} | |
key: ${{ env.OS_VER }}-${{ env.CC }}-${{ hashFiles('**/common.env') }}-${{ hashFiles('**/ubuntu.env') }}-v${{ env.CACHE_VER }} | |
- name: Install tebako | |
run: sudo gem install tebako | |
- name: Package metanorma | |
run: | | |
make build/bin/metanorma-linux-gnu-x86_64 | |
mv -T build/bin/metanorma-linux-gnu-x86_64 build/bin/metanorma-linux-x86_64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: metanorma-linux-x86_64 | |
path: build/bin/metanorma-linux-x86_64 | |
- name: Verify packaging | |
run: | | |
build/bin/metanorma-linux-x86_64 --tebako-extract extracted_source_filesystem | |
diff -r extracted_source_filesystem .archive/tebako/output/source_filesystem | |
- name: smoke test | |
run: build/bin/metanorma-linux-x86_64 help | |
build-matrix: | |
uses: metanorma/ci/.github/workflows/build-sample-matrix.yml@main | |
with: | |
smoke: false | |
flavors-only: true | |
public-only: true | |
test: | |
needs: [build, build-matrix] | |
runs-on: ubuntu-20.04 | |
continue-on-error: ${{ matrix.flavor.experimental }} | |
strategy: | |
max-parallel: 5 | |
fail-fast: false | |
matrix: ${{ fromJson(needs.build-matrix.outputs.samples-matrix) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- run: rm Gemfile | |
- uses: actions/download-artifact@v3 | |
with: | |
name: metanorma-linux-x86_64 | |
path: build/bin | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.relaton | |
key: relaton-linux-${{ matrix.flavor.id }} | |
restore-keys: relaton-linux-${{ matrix.flavor.id }} | |
- run: chmod +x build/bin/metanorma-linux-x86_64 | |
- name: Fetch samples (${{ matrix.flavor.id }}) | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
repository: metanorma/mn-samples-${{ matrix.flavor.id }} | |
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }} | |
path: ${{ github.workspace }}/samples | |
fetch-depth: 1 | |
- name: Test (${{ matrix.flavor.id }}) | |
timeout-minutes: 45 | |
run: | | |
build/bin/metanorma-linux-x86_64 \ | |
site generate samples \ | |
-c samples/metanorma.yml \ | |
--agree-to-terms | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: site-${{ matrix.flavor.id }} | |
path: _site | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: metanorma-linux-x86_64 | |
path: build/bin | |
- name: Package binary into archive | |
run: | | |
chmod +x build/bin/metanorma-linux-x86_64 | |
mv build/bin/metanorma-linux-x86_64 metanorma-linux-x86_64 | |
tar -czvf metanorma-linux-x86_64.tgz metanorma-linux-x86_64 | |
- name: Calculate SHA256 hash | |
run: | | |
sha256sum metanorma-linux-x86_64.tgz | cut -d ' ' -f1 > metanorma-linux-x86_64.tgz.sha256.txt | |
- uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
metanorma-linux-x86_64.tgz | |
metanorma-linux-x86_64.tgz.sha256.txt | |
- uses: peter-evans/repository-dispatch@v1 | |
with: | |
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }} | |
repository: metanorma/metanorma-snap | |
event-type: ${{ github.repository }} | |
client-payload: '{ "ref": "${{ github.ref }}" }' | |
- uses: peter-evans/repository-dispatch@v1 | |
with: | |
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }} | |
repository: metanorma/homebrew-metanorma | |
event-type: ${{ github.repository }} | |
client-payload: '{ "ref": "${{ github.ref }}" }' |