Skip to content

Commit

Permalink
add build step and github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasmcnulty committed Mar 9, 2021
1 parent f421915 commit c4ad7df
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 5 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '*' # Any tag

name: Upload Release Asset

jobs:
# https://github.com/actions/upload-release-asset#example-workflow---upload-a-release-asset
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set vars stage 1
run: |
export TAG=$(echo ${{ github.ref }} | cut -d'/' -f3)
echo "release=$(echo $TAG | cut -d'-' -f1)" >> $GITHUB_ENV
echo "target=$(echo $TAG | cut -d'-' -f2)" >> $GITHUB_ENV
echo "subtarget=$(echo $TAG | cut -d'-' -f3)" >> $GITHUB_ENV
- name: Set vars stage 2
run: |
echo "target_dir=./builder/bin/targets/${{ env.target }}/${{ env.subtarget }}" >> $GITHUB_ENV
echo "combined_img=openwrt-${{ env.release }}-${{ env.target }}-${{ env.subtarget }}-combined-squashfs.img.gz" >> $GITHUB_ENV
- name: Build project
run: |
make release="${{ env.release }}" target="${{ env.target }}" subtarget="${{ env.subtarget }}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload combined image
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.target_dir }}/${{ env.combined_img }}
asset_name: ${{ env.combined_img }}
asset_content_type: application/gzip
- name: Upload sha256sums
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.target_dir }}/sha256sums
asset_name: sha256sums
asset_content_type: application/gzip
37 changes: 32 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
release = 19.07.7
target = x86
subtarget = 64
release ?= 19.07.7
target ?= x86
subtarget ?= 64
builder_url = https://downloads.openwrt.org/releases/$(release)/targets/$(target)/$(subtarget)/openwrt-imagebuilder-$(release)-$(target)-$(subtarget).Linux-x86_64.tar.xz
builder_filename = $(notdir $(builder_url))
checksums_url = https://downloads.openwrt.org/releases/$(release)/targets/$(target)/$(subtarget)/sha256sums

build_profile = Generic
build_packages = \
rsyslog \
luci \
luci-app-unbound \
unbound-daemon-heavy \
luci-app-wireguard \
luci-proto-wireguard \
python3-light \
python3-logging \
python3-ctypes \
libustream-openssl20150806 \
ca-bundle \
ca-certificates \
nmap \
tcpdump \
bwm-ng \
iperf \
screen

.PHONY: all
all: install-deps get-builder build

install-deps:
# https://openwrt.org/docs/guide-user/additional-software/imagebuilder#debianubuntu
sudo apt-get update
Expand All @@ -15,6 +38,10 @@ get-builder:
wget -q $(builder_url) -O $(builder_filename)
wget -q $(checksums_url) -O sha256sums
grep $(builder_filename) sha256sums | sha256sum --check --status
mkdir -p builder/
tar -xf $(builder_filename) -C builder/ --strip-components=1

build:
rm -rf builder && mkdir builder/
tar -xf $(builder_filename) -C builder/ --strip-components=1
cd builder/ && make image PROFILE=$(build_profile) PACKAGES="$(build_packages)"
du -hs builder/bin/targets/$(target)/$(subtarget)/*
cat builder/bin/targets/$(target)/$(subtarget)/sha256sums

0 comments on commit c4ad7df

Please sign in to comment.