build #318
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: build | |
on: | |
schedule: | |
- cron: '0 0 */7 * *' | |
workflow_dispatch: | |
inputs: | |
releaseNotes: | |
description: 'Release Notes' | |
required: false | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
name: release | |
steps: | |
- name: Checkout damianperera/openwrt-rpi | |
uses: actions/checkout@v4 | |
- name: Checkout wulfy23/rpi4 | |
uses: actions/checkout@v4 | |
with: | |
repository: wulfy23/rpi4 | |
path: wulfy | |
- name: Prepare OpenWrt image | |
run: | | |
pwd=$(pwd) | |
cd wulfy/builds | |
cd "$(ls -t1 -d rpi-4_*/ | head -n1)" | |
gunzip -v *{fac,sys}.img.gz || echo Extraction completed with warnings | |
baseFileName=$(ls *{fac,sys}.img 2>/dev/null | head -n1) | |
for file in *{fac,sys}.img; do [ -e "$file" ] && mv "$file" $pwd/rpi.img; done | |
cd $pwd | |
echo "imagePath=${pwd}/rpi.img" >> $GITHUB_ENV | |
echo "baseFileName=$baseFileName" >> $GITHUB_ENV | |
- name: Mount OpenWrt image | |
id: mount-image | |
uses: damianperera/mount-image-action@v1 | |
with: | |
imagePath: ${{ env.imagePath }} | |
mountPoint: /mnt/rpi4 | |
- name: Update configs | |
run: | | |
sudo cp config/* ${{ steps.mount-image.outputs.rootMountLocation }}/etc/config/ | |
- name: Unmount OpenWrt image | |
uses: damianperera/unmount-image-action@v1 | |
with: | |
imagePath: ${{ env.imagePath }} | |
bootDeviceMapper: ${{ steps.mount-image.outputs.bootDeviceMapper }} | |
rootDeviceMapper: ${{ steps.mount-image.outputs.rootDeviceMapper }} | |
- name: Compress build | |
run: | | |
gzip -v9 rpi.img | |
- name: Create release notes | |
run: | | |
latestDownstreamRepoCommit=$(git log -1 --pretty=%B | sed -n '1p') | |
latestDownstreamRepoCommitId=$(git rev-parse --short HEAD) | |
latestUpstreamRepoCommit=$(cd wulfy && git log -1 --pretty=%B) | |
latestUpstreamRepoCommitId=$(cd wulfy && git rev-parse --short HEAD) | |
baseFileName=${{ env.baseFileName }} | |
echo "**build type:** \`$GITHUB_EVENT_NAME\`" > CHANGELOG.txt | |
echo "**base:** \`${baseFileName%.img}\`" >> CHANGELOG.txt | |
[[ "${baseFileName}" == *fac* ]] && echo "**release type:** \`factory\`" >> CHANGELOG.txt || [[ "${baseFileName}" == *sys* ]] && echo "**release type:** \`sysupgrade\`" >> CHANGELOG.txt | |
echo "**[wulfy/rpi4](https://github.com/wulfy23/rpi4) changes:** \`$latestUpstreamRepoCommit\` on commit [$latestUpstreamRepoCommitId](https://github.com/wulfy23/rpi4/commit/$latestUpstreamRepoCommitId)" >> CHANGELOG.txt | |
echo "**[damianperera/openwrt-rpi](https://github.com/damianperera/openwrt-rpi) changes:** \`$latestDownstreamRepoCommit\` on commit [$latestDownstreamRepoCommitId](https://github.com/damianperera/openwrt-rpi/commit/$latestDownstreamRepoCommitId)" >> CHANGELOG.txt | |
[[ -z "${{ github.event.inputs.releaseNotes }}" ]] && echo No custom release notes || echo "### Release Notes" >> CHANGELOG.txt && echo ${{ github.event.inputs.releaseNotes }} >> CHANGELOG.txt | |
echo "CHANGELOG:" && cat CHANGELOG.txt | |
- name: Create release tag | |
id: create_tag | |
run: | | |
echo "tag=$(date +%Y.%m.%d.%H%M%S)" >> $GITHUB_OUTPUT | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
body_path: CHANGELOG.txt | |
tag_name: ${{ steps.create_tag.outputs.tag }} | |
release_name: ${{ steps.create_tag.outputs.tag }} | |
draft: true | |
prerelease: false | |
- name: Upload release assets | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./rpi.img.gz | |
asset_name: openwrt.img.gz | |
asset_content_type: application/gzip | |
- name: Publish release | |
uses: eregon/publish-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ steps.create_release.outputs.id }} |