Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build deb and rpm packages for clients #24

Merged
merged 36 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6c47a07
Initial version, only deb for now
bedroge Jun 26, 2020
0bf7c69
Add deb packaging workflow
bedroge Jun 30, 2020
5ae0a48
Change CI for building packages
bedroge Jun 30, 2020
aad4c70
Add freedomofpress.build-debian-package role
bedroge Jun 30, 2020
9133e06
Use Debian stretch for CI
bedroge Jun 30, 2020
d60f962
Upload packages
bedroge Jun 30, 2020
3204d8f
Upload only the package
bedroge Jun 30, 2020
d29a7fe
test rpmbuild command
bedroge Jul 1, 2020
64d3561
install rpmbuild
bedroge Jul 1, 2020
80c1e1e
Added role for making rpms
bedroge Jul 1, 2020
be58e41
Add build dir to .gitignore
bedroge Jul 1, 2020
9add777
Role for making RPMs
bedroge Jul 1, 2020
14ee0aa
Updated git action, upload rpm
bedroge Jul 1, 2020
fb6a445
Fix lint issues
bedroge Jul 1, 2020
b44a5d4
Rename task
bedroge Jul 1, 2020
9d391ed
Improved spec file template
bedroge Jul 1, 2020
055038a
Generate list of files for spec file
bedroge Jul 1, 2020
5337f74
Merge branch 'master' into build_packages
bedroge Sep 29, 2020
1d38350
Remove custom build-rpm-package role
bedroge Sep 29, 2020
aef3885
Rename playbook build-packages to prepare-client-packages
bedroge Sep 29, 2020
cdd0b20
spec template file for building packages
bedroge Sep 29, 2020
b361f83
Rename and change workflow
bedroge Sep 29, 2020
1d0ae6a
Don't run CI on non-master branches
bedroge Sep 29, 2020
e058f49
Set file permissions on generated/copied files
bedroge Sep 29, 2020
89b8658
remove roles dir
bedroge Sep 29, 2020
24493a1
Fix for not finding group_vars
bedroge Sep 29, 2020
99481e2
remove spec file for packages
bedroge Sep 29, 2020
88579b0
use fpm instead of nfpm
bedroge Sep 29, 2020
f157b95
use fpm instead of nfpm
bedroge Sep 29, 2020
3548c66
Add description to package
bedroge Sep 29, 2020
1f6bd7d
add modes for copy tasks
bedroge Sep 29, 2020
ab498e6
Fix for not finding group_vars
bedroge Sep 29, 2020
bc70d89
small syntax fix
bedroge Sep 29, 2020
01f915b
Update README for client packages
bedroge Sep 30, 2020
f614ebd
Update README for client packages
bedroge Sep 30, 2020
09a24ef
rpm -> deb
bedroge Oct 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/build-client-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Build client packages

on:
push:
branches:
- master
tags:
- 'v*'
bedroge marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches:
- master

jobs:

build-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Get the version number for the packages
id: get_version
# If this is a tag, use the tag name (e.g. v1.2.3) without v as version number.
# Otherwise, just use 0.0.
bedroge marked this conversation as resolved.
Show resolved Hide resolved
run: |
VERSION=0.0
REF_NAME=${{ github.ref }}
[[ $REF_NAME == refs/tags/v* ]] && VERSION=${REF_NAME/refs\/tags\/v/}
echo ::set-output name=version::${VERSION}

# The next step uses a custom Ansible inventory, and due to that it cannot find
# the group_vars folder inside the inventory folder. This symlink fixes that.
- name: Make symlink to group_vars
run: ln -s inventory/group_vars

- name: Prepare package source
uses: roles-ansible/check-ansible-debian-stretch-action@master
with:
targets: "./prepare-client-packages.yml"
hosts: "localhost"

- name: Build RPM package
id: build-rpm
uses: kentik/[email protected]
with:
name: cvmfs-config-eessi
version: ${{ steps.get_version.outputs.version }}
arch: x86_64
bedroge marked this conversation as resolved.
Show resolved Hide resolved
format: rpm
package: package/client_packages_metadata.yaml

- name: Build Deb package
id: build-deb
uses: kentik/[email protected]
with:
name: cvmfs-config-eessi
version: ${{ steps.get_version.outputs.version }}
arch: x86_64
bedroge marked this conversation as resolved.
Show resolved Hide resolved
format: deb
package: package/client_packages_metadata.yaml

- name: Upload Deb package as artifact
uses: actions/upload-artifact@v2
with:
name: Deb package
path: ${{ steps.build-deb.outputs.package }}

- name: Upload RPM package as artifact
uses: actions/upload-artifact@v2
with:
name: RPM package
path: ${{ steps.build-rpm.outputs.package }}

release:
needs: build-packages
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download Deb package
uses: actions/download-artifact@v2
with:
name: Deb package

- name: Download RPM package
uses: actions/download-artifact@v2
with:
name: RPM package

- name: Find filenames of downloaded packages
id: find_filenames
shell: bash
run: |
rpmfile="$(ls -1 *.rpm)"
debfile="$(ls -1 *.deb)"
echo ::set-output name=rpmfile::${rpmfile}
echo ::set-output name=debfile::${debfile}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Filesystem Layer ${{ github.ref }}
draft: false
prerelease: false

- name: Upload RPM as release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.find_filenames.outputs.rpmfile }}
asset_name: ${{ steps.find_filenames.outputs.rpmfile }}
asset_content_type: application/x-rpm

- name: Upload Deb as release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.find_filenames.outputs.debfile }}
asset_name: ${{ steps.find_filenames.outputs.debfile }}
asset_content_type: application/x-debian-package
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
hosts
roles/
58 changes: 58 additions & 0 deletions prepare-client-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Prepare the input files for the Debian (deb) and Redhat (rpm) packages for CVMFS clients.
---
- name: Prepare Deb and RPM packages
hosts: localhost
vars:
package_vendor: EESSI
package_maintainer: EESSI <[email protected]>
package_description: CVMFS config repository package for EESSI.
package_source_dir: "{{ lookup('env', 'GITHUB_WORKSPACE') | default('/tmp', True) }}/package"
tasks:
- name: Create directory structure for the CVMFS config
file:
path: "{{ item }}"
state: directory
mode: 0775
with_items:
- "{{ package_source_dir }}"
- "{{ package_source_dir }}/etc"
- "{{ package_source_dir }}/etc/cvmfs"
- "{{ package_source_dir }}/etc/cvmfs/keys"
- "{{ package_source_dir }}/etc/cvmfs/keys/{{ eessi_cvmfs_config_repo.domain }}"
- "{{ package_source_dir }}/etc/cvmfs/config.d"
- "{{ package_source_dir }}/etc/cvmfs/default.d"

- name: Make EESSI CVMFS public key file
copy:
content: "{{ eessi_cvmfs_config_repo.key.key }}"
dest: "{{ package_source_dir }}{{ eessi_cvmfs_config_repo.key.path }}"
mode: 0644

- name: Make EESSI CVMFS configuration file
copy:
content: |
CVMFS_SERVER_URL="{{ eessi_cvmfs_config_repo.urls|join(',') }}"
CVMFS_PUBLIC_KEY="{{ eessi_cvmfs_config_repo.key.path }}"
dest: "{{ package_source_dir }}/etc/cvmfs/config.d/{{ eessi_cvmfs_config_repo.repository.repository }}.conf"
mode: 0644

- name: Make EESSI CVMFS default configuration file
copy:
content: |
CVMFS_CONFIG_REPOSITORY="{{ eessi_cvmfs_config_repo.repository.repository }}"
CVMFS_DEFAULT_DOMAIN="{{ eessi_cvmfs_config_repo.domain }}"
dest: "{{ package_source_dir }}/etc/cvmfs/default.d/80-eessi-cvmfs.conf"
mode: 0644

- name: Register all files to be included in the package
find:
paths: "{{ package_source_dir }}/"
recurse: yes
file_type: file
register: pkg_files

- name: Make package metadata file
template:
src: client_packages_metadata.j2
dest: "{{ package_source_dir }}/client_packages_metadata.yaml"
mode: 0644
12 changes: 12 additions & 0 deletions templates/client_packages_metadata.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is used as metadata file for the generation of client packages.
# See: https://github.com/kentik/pkg
meta:
description: {{ package_description }}
vendor: {{ package_vendor }}
maintainer: {{ package_maintainer }}
files:
{% for file in pkg_files.files %}
"{{ file.path | regex_replace(package_source_dir) }}":
file: "{{ file.path | regex_replace(package_source_dir + '/package/') }}"
user: "root"
{% endfor %}