Skip to content

Commit

Permalink
Rework the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Oct 9, 2023
1 parent b32d17e commit 0ef957f
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 109 deletions.
162 changes: 67 additions & 95 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,115 +4,87 @@ on:
tags:
- v*
branches:
- release/*
- test-release/*

jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- id: version
run: echo "version=${ref##test-release/}" >> $GITHUB_OUTPUT
env:
ref: ${{ github.ref_name }}

build-releases:
name: Build release
runs-on: ubuntu-latest
needs: get-version
strategy:
matrix:
arch:
[
"linux/amd64 x86_64",
"linux/arm64/v8 aarch64",
"linux/arm/v7 armv7h"
]
name: Build ${{ matrix.arch }}
runs-on: ubuntu-latest
platform:
- target: x86_64-unknown-linux-gnu
arch: x86_64

- target: aarch64-unknown-linux-gnu
arch: aarch64

- target: armv7-unknown-linux-gnueabihf
arch: armv7h

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- uses: actions/checkout@v2
- run: sudo apt-get install -y gettext binutils
- uses: actions-rs/toolchain@v1
with:
version: latest
- name: Read info
id: tags
shell: bash
run: |
arch="${{ matrix.arch }}"
echo ::set-output name=PLATFORM::${arch%% *}
echo ::set-output name=ARCH::${arch##* }
- name: Build ${{ matrix.arch }} release
shell: bash
run: |
arch="${{ matrix.arch }}"
PLATFORM=${arch%% *}
ARCH=${arch##* }
mkdir artifacts
docker buildx build --platform $PLATFORM \
--tag paru:$ARCH \
--load \
.
docker create --name paru-$ARCH paru:$ARCH
docker cp paru-$ARCH:/app/paru.tar.zst paru-$ARCH.tar.zst
docker container rm paru-$ARCH
mv paru-*.tar.zst artifacts
toolchain: stable
target: ${{ matrix.platform.target }}
override: true
- run: cargo install cross
- name: Build Paru
run: ./scripts/dist
env:
CARGO_BUILD_TARGET: ${{ matrix.platform.target }}
- uses: actions/upload-artifact@v2
with:
name: paru-${{ steps.tags.outputs.arch }}
path: artifacts
name: paru-${{ needs.get-version.outputs.version }}-${{ matrix.platform.arch }}.tar.zst
path: paru-${{ matrix.platform.arch }}.tar.zst

create_release:
name: Create release from this build
needs: [build-releases]
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-releases, get-version]
outputs:
release-url: ${{ steps.create-release.outputs.url }}
steps:
- name: Read info
id: tags
shell: bash
run: |
echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
- uses: actions/download-artifact@v2
with:
name: paru-x86_64
- uses: actions/download-artifact@v2
with:
name: paru-aarch64
- uses: actions/download-artifact@v2
with:
name: paru-armv7h
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tags.outputs.tag }}
release_name: ${{ steps.tags.outputs.tag }}
draft: true
prerelease: false
- name: Upload x86_64 asset
id: upload-release-asset-x86_64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./paru-x86_64.tar.zst
asset_name: paru-${{ steps.tags.outputs.tag }}-x86_64.tar.zst
asset_content_type: application/tar+zstd
- name: Upload aarch64 asset
id: upload-release-asset-aarch64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.get-version.outputs.version }}
release_name: Paru v${{ needs.get-version.outputs.version }}
draft: true
prerelease: false

upload-binaries:
name: Upload binaries to Githib relase
runs-on: ubuntu-latest
needs: [release, get-version]
strategy:
matrix:
arch: [x86_64, aarch64, armv7h]
steps:
- uses: actions/download-artifact@v3
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./paru-aarch64.tar.zst
asset_name: paru-${{ steps.tags.outputs.tag }}-aarch64.tar.zst
asset_content_type: application/tar+zstd
- name: Upload armv7h asset
id: upload-release-asset-armv7h
uses: actions/upload-release-asset@v1
path: paru-${{ needs.get-version.outputs.version }}-${{ matrix.arch }}.tar.zstd
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./paru-armv7h.tar.zst
asset_name: paru-${{ steps.tags.outputs.tag }}-armv7h.tar.zst
upload_url: ${{ needs.release.outputs.release-url }}
asset_path: paru-${{ needs.get-version.outputs.version }}-${{ matrix.arch }}.tar.ztd
asset_content_type: application/tar+zstd

13 changes: 13 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

[target.x86_64-unknown-linux-gnu]
dockerfile = "Dockerfile"

[target.aarch64-unknown-linux-gnu]
dockerfile = "Dockerfile"

[target.armv7-unknown-linux-gnueabihf]
dockerfile = "Dockerfile"

[target.riscv64gc-unknown-linux-gnu]
dockerfile = "Dockerfile"

24 changes: 15 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
FROM lopsided/archlinux:devel
FROM debian:unstable
ARG PACMAN_VER=6.0.2

WORKDIR /app
RUN apt-get update -y
RUN apt-get install -y build-essential git libcurl4-openssl-dev curl meson ninja-build\
libarchive-dev pkg-config libgpgme-dev libssl-dev clang-16

COPY ../ .

RUN pacman -Sy --noconfirm archlinux-keyring
RUN pacman -Su --noconfirm rustup
RUN rustup default nightly
RUN --mount=type=tmpfs,target=/root/.cargo ./scripts/dist
RUN ./scripts/dist
RUN curl -O https://sources.archlinux.org/other/pacman/pacman-${PACMAN_VER}.tar.xz
RUN tar -xf pacman-${PACMAN_VER}.tar.xz
WORKDIR pacman-${PACMAN_VER}
RUN meson setup --prefix=/usr \
--buildtype=plain \
-Dscriptlet-shell=/usr/bin/bash \
-Dldconfig=/usr/bin/ldconfig \
build

RUN meson compile -C build
RUN meson install -C build
14 changes: 10 additions & 4 deletions scripts/dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/sh
#!/bin/bash
set -e
cargo build --release --locked --target-dir target -Z sparse-registry

TARGET=$CARGO_BUILD_TARGET
CARCH=${TARGET//-*}

cross build --features generate --release --locked --target-dir target
scripts/mkmo locale/
strip target/release/paru
tar --zstd -cfparu.tar.zst man completions paru.conf locale -C target/release paru
mv target/**/release/paru ./
strip paru
tar --zstd -cf paru-${CARCH}.tar.zst man completions paru.conf locale paru

2 changes: 1 addition & 1 deletion scripts/mkmo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

if [ -z "$1" ]; then
Expand Down

0 comments on commit 0ef957f

Please sign in to comment.