From 0c36376f330401e34c1335756f0bd13c942b2405 Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Thu, 28 Mar 2024 23:36:01 +0100 Subject: [PATCH] Automate release process --- .github/workflows/build.yml | 42 +++++++++++++++++++++++++++++++++++++ .gitignore | 8 +++++++ 0bootstrap.xml | 13 ++++++------ 0bootstrap.xml.template | 38 +++++++++++++++++++++++++++++++++ 0install.sh | 42 +++++++++++++++++++++++++++++++++++++ GitVersion.yml | 26 +++++++++++++++++++++++ 6 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 0bootstrap.xml.template create mode 100755 0install.sh create mode 100644 GitVersion.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a5453d1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Build +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Prepare + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + show-progress: false + - uses: gittools/actions/gitversion/setup@v1.1.1 + with: + versionSpec: '5.12.x' + - uses: gittools/actions/gitversion/execute@v1.1.1 + id: gitversion + + # Build + - name: Inject version number + run: sed -i "s/^version = '.*'$/version = '${{steps.gitversion.outputs.legacySemVer}}'/" 0bootstrap + - name: 0template + run: ./0install.sh run https://apps.0install.net/0install/0template.xml 0bootstrap.xml.template version=${{steps.gitversion.outputs.legacySemVer}} + #- name: 0test + # run: ./0install.sh run https://apps.0install.net/0install/0test.xml 0bootstrap-${{steps.gitversion.outputs.legacySemVer}}.xml + + # Release + - name: Create GitHub Release + if: github.ref_type == 'tag' + uses: softprops/action-gh-release@v1 + with: + files: | + 0bootstrap-${{steps.gitversion.outputs.legacySemVer}}.xml + 0bootstrap-${{steps.gitversion.outputs.legacySemVer}}.tar.bz2 + - name: Publish feed + if: github.ref_type == 'tag' + env: + GH_TOKEN: ${{secrets.PERSONAL_TOKEN}} + run: > + gh workflow run --repo=0install/apps Incoming + -f feed_url=https://github.com/${{github.repository}}/releases/download/${{github.ref_name}}/0bootstrap-${{steps.gitversion.outputs.legacySemVer}}.xml + -f archive_url=https://github.com/${{github.repository}}/releases/download/${{github.ref_name}}/0bootstrap-${{steps.gitversion.outputs.legacySemVer}}.tar.bz2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12ecb7f --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# Caches +__pycache__/ +*.py[cod] +.idea/ + +# Output +/0bootstrap-*.xml +/0bootstrap-*.tar.bz2 diff --git a/0bootstrap.xml b/0bootstrap.xml index 406f0d2..52a9f25 100644 --- a/0bootstrap.xml +++ b/0bootstrap.xml @@ -1,5 +1,4 @@ - 0bootstrap create a native package that installs 0install and a program @@ -13,23 +12,25 @@ https://docs.0install.net/tools/0bootstrap/ - + - + - + - + - + + + diff --git a/0bootstrap.xml.template b/0bootstrap.xml.template new file mode 100644 index 0000000..5b1c813 --- /dev/null +++ b/0bootstrap.xml.template @@ -0,0 +1,38 @@ + + + 0bootstrap + create a native package that installs 0install and a program + + 0bootstrap creates native binary packages (debs, RPMs, exes, etc) for use on systems + where 0install is not already present. + + Unlike 0export, the packages do not contain the programs themselves. They are just + launchers that trigger 0install to get the actual program. + + + https://docs.0install.net/tools/0bootstrap/ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/0install.sh b/0install.sh new file mode 100755 index 0000000..376adcc --- /dev/null +++ b/0install.sh @@ -0,0 +1,42 @@ +#!/bin/sh +set -e + +if [ "$#" -eq 0 ]; then + echo "This script runs 0install from your PATH or downloads it on-demand." + echo "" + echo "To run 0install commands without adding 0install to your PATH:" + echo "./0install.sh --help" + echo "./0install.sh COMMAND [OPTIONS]" + echo "" + echo "To install to /usr/local:" + echo "sudo ./0install.sh install local" + echo "" + echo "To install to your home directory:" + echo "./0install.sh install home" + exit 1 +fi + +download() { + zeroinstall_release=0install-$(uname | tr '[:upper:]' '[:lower:]')-$(uname -m)-${ZEROINSTALL_VERSION:-latest} + download_dir=~/.cache/0install.net/$zeroinstall_release + + if [ ! -f $download_dir/files/0install ]; then + echo "Downloading 0install..." >&2 + rm -rf $download_dir + mkdir -p $download_dir + curl -sSL https://get.0install.net/$zeroinstall_release.tar.bz2 | tar xj --strip-components 1 --directory $download_dir + fi +} + +if [ "$1" = "install" ]; then + download + shift 1 + $download_dir/install.sh "$@" +else + if command -v 0install > /dev/null 2> /dev/null; then + 0install "$@" + else + download + $download_dir/files/0install "$@" + fi +fi diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..d0f96d2 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,26 @@ +mode: ContinuousDeployment + +# Generate 0install-compatible version numbers +branches: + # Mainline branches + main: + tag: rc-pre + develop: + tag: pre + increment: patch + + # Stabilization branches + release: + tag: rc + hotfix: + tag: rc + + # Topic branches + feature: + tag: pre-pre + pull-request: + tag: pre-pre + fallback: + source-branches: [main] + regex: ^(?!main|master|develop|release|hotfix|feature|pull|pr) + tag: pre-pre