Release #22
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
description: New version number in X.Y.Z | |
required: true | |
jobs: | |
push-version-number: | |
name: Push version number | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone develop repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
ref: "develop" | |
- name: Get current version | |
id: current-version | |
shell: bash | |
run: | | |
version=$(cat ./src/version) | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
- name: Push version number | |
if: steps.current-version.outputs.version != github.event.inputs.version | |
shell: bash | |
run: | | |
echo ${{ github.event.inputs.version }} > ./src/version | |
- name: git add & commit & push | |
if: steps.current-version.outputs.version != github.event.inputs.version | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: "./src/version" | |
default_author: github_actions | |
message: "chore: push version number to v${{ github.event.inputs.version }}" | |
push: true | |
release: | |
name: Create Release | |
# needs: update-master-branch | |
runs-on: ubuntu-latest | |
outputs: | |
id: ${{ steps.create-release.outputs.id }} | |
date: ${{ steps.base-name.outputs.date }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: "v2.1.x" | |
fetch-depth: 0 | |
- name: Get latest tag | |
id: latest_tag | |
shell: bash | |
run: | | |
echo "TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_OUTPUT | |
- name: Generate a changelog | |
uses: orhun/git-cliff-action@v1 | |
id: changelog | |
with: | |
config: ./cliff-release.toml | |
args: ${{ steps.latest_tag.outputs.TAG_NAME }}..HEAD | |
- name: Create empty release | |
id: create-release | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: "RatOS-v${{ github.event.inputs.version }}" | |
tag_name: v${{ github.event.inputs.version }} | |
body: ${{ steps.changelog.outputs.content }} | |
draft: true | |
- name: Create Date | |
id: base-name | |
if: always() | |
shell: bash | |
run: | | |
NOW="$(date +"%Y-%m-%d")" | |
echo "date=${NOW}" >> $GITHUB_OUTPUT | |
matrix: | |
name: Create Matrix | |
needs: release | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: v2.1.x | |
- name: Create Matrix | |
id: set-matrix | |
run: | | |
PY_INT=$(command -v python3) | |
CONFIG="${{ github.workspace }}/.github/workflow_config.yml" | |
GROUP="release" | |
$PY_INT ${{ github.workspace }}/.github/scripts/setup_matrix.py -c $CONFIG -g $GROUP --git | |
build: | |
needs: [release, matrix] | |
runs-on: ubuntu-latest | |
outputs: | |
base_name: ${{ steps.move-image.outputs.base_name }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: ${{ fromJson(needs.matrix.outputs.matrix) }} | |
steps: | |
- name: Cache aptitude | |
uses: actions/cache@v2 | |
with: | |
path: repository/src/workspace/aptcache | |
key: ${{ runner.os }}-apt-get-${{ hashFiles('**/apt.txt') }} | |
restore-keys: | | |
${{ runner.os }}-apt-get- | |
- name: Build image | |
id: build | |
uses: mainsail-crew/MainsailOS-actions/build-image@master | |
with: | |
config: ${{ matrix.config }} | |
build-ref: v2.1.x | |
- name: Upload failed Logfile | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: failed-${{ steps.move-image.outputs.image }}.log | |
path: repository/src/build.log | |
- name: Rename image file | |
id: move-image | |
shell: bash | |
run: | | |
WORKSPACE=$(echo ${{ github.workspace }}) | |
sudo chown -R $USER:$USER $WORKSPACE/repository/src/workspace || true | |
sudo chmod 0775 -R $WORKSPACE/repository/src/workspace || true | |
source repository/src/config | |
base_name="${{ needs.release.outputs.date }}-${DIST_NAME}-${DIST_VERSION}" | |
image="${base_name}-${{ steps.build.outputs.type }}-${{ steps.build.outputs.sbc }}" | |
mv repository/src/workspace/*.img $image.img | |
echo "base_name=${base_name}" >> $GITHUB_OUTPUT | |
echo "image=${image}" >> $GITHUB_OUTPUT | |
- name: Compressing Image | |
shell: bash | |
run: | | |
CPU_COUNT="$(nproc)" | |
echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m" | |
xz -efkvz9T"${CPU_COUNT}" ${{ steps.move-image.outputs.image }}.img || true | |
- name: Upload Compressing Image | |
if: success() | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ needs.release.outputs.id }} | |
file: ${{ steps.move-image.outputs.image }}.img.xz | |
- name: Calculating checksums | |
id: checksums | |
shell: bash | |
run: | | |
sha256sum ${{ steps.move-image.outputs.image }}.img > ${{ steps.move-image.outputs.image }}.img.sha256 | |
image_checksum=`cat ${{ steps.move-image.outputs.image }}.img.sha256 | awk '{ print $1 }'` | |
echo "image=${image_checksum}" >> $GITHUB_OUTPUT | |
sha256sum ${{ steps.move-image.outputs.image }}.img.xz > ${{ steps.move-image.outputs.image }}.img.xz.sha256 | |
zip_checksum=`cat ${{ steps.move-image.outputs.image }}.img.xz.sha256 | awk '{ print $1 }'` | |
echo "zip=${zip_checksum}" >> $GITHUB_OUTPUT | |
- name: Upload Checksums | |
if: success() | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ needs.release.outputs.id }} | |
file: ${{ steps.move-image.outputs.image }}.img.sha256;${{ steps.move-image.outputs.image }}.img.xz.sha256 | |
- name: Calculating filesizes | |
id: filesizes | |
shell: bash | |
run: | | |
image_filesize=`wc -c ${{ steps.move-image.outputs.image }}.img | awk '{print $1}'` | |
echo "image=${image_filesize}" >> $GITHUB_OUTPUT | |
zip_filesize=`wc -c ${{ steps.move-image.outputs.image }}.img.xz | awk '{print $1}'` | |
echo "zip=${zip_filesize}" >> $GITHUB_OUTPUT | |
- name: Debug output | |
run: | | |
echo "release-id: ${{ needs.release.outputs.id }}" | |
echo "release-version: ${{ needs.release.outputs.version }}" | |
echo "image-name: ${{ steps.move-image.outputs.image }}" | |
echo "checksum image: ${{ steps.checksums.outputs.image }}" | |
echo "checksum zip: ${{ steps.checksums.outputs.zip }}" | |
echo "filesize-image: ${{ steps.filesizes.outputs.image }}" | |
echo "filesize-zip: ${{ steps.filesizes.outputs.zip }}" | |
- name: Generate JSON | |
id: json | |
uses: actions/github-script@v6 | |
env: | |
name: "Mainsail OS ${{ github.event.inputs.version }}" | |
description: "Type: ${{ steps.build.outputs.type }}, SBC: ${{ steps.build.outputs.sbc }}" | |
type: "${{ steps.build.outputs.type }}" | |
sbc: "${{ steps.build.outputs.sbc }}" | |
url: "https://github.com/mainsail-crew/MainsailOS/releases/download/${{ github.event.inputs.version }}/${{ steps.move-image.outputs.image }}.img.xz" | |
icon: "https://os.mainsail.xyz/rpi-imager.png" | |
init_format: "systemd" | |
release_date: "${{ needs.release.outputs.date }}" | |
extract_size: ${{ steps.filesizes.outputs.image }} | |
extract_sha256: "${{ steps.checksums.outputs.image }}" | |
image_download_size: ${{ steps.filesizes.outputs.zip }} | |
image_download_sha256: "${{ steps.checksums.outputs.zip }}" | |
with: | |
result-encoding: string | |
script: | | |
const fs = require('fs') | |
let { name, description, type, sbc, url, icon, init_format, release_date, extract_size, extract_sha256, image_download_size, image_download_sha256 } = process.env | |
if (sbc === 'rpi32') name += ' 32-Bit (recommend)' | |
else if (sbc === 'rpi64') name += ' 64-Bit' | |
const json = JSON.stringify({ | |
name, | |
description, | |
url, | |
icon, | |
init_format, | |
release_date, | |
extract_size: parseInt(extract_size), | |
extract_sha256, | |
image_download_size: parseInt(image_download_size), | |
image_download_sha256 | |
}) | |
fs.writeFileSync("./${{ steps.move-image.outputs.image }}.json", json) | |
- name: Debug output | |
shell: bash | |
run: | | |
cat "./${{ steps.move-image.outputs.image }}.json" | |
- name: Upload JSON | |
if: success() | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ needs.release.outputs.id }} | |
file: ${{ steps.move-image.outputs.image }}.json |