Skip to content

Commit

Permalink
Automate release process
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Mar 28, 2024
1 parent 65ec02a commit 0c36376
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 6 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
versionSpec: '5.12.x'
- uses: gittools/actions/gitversion/[email protected]
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Caches
__pycache__/
*.py[cod]
.idea/

# Output
/0bootstrap-*.xml
/0bootstrap-*.tar.bz2
13 changes: 7 additions & 6 deletions 0bootstrap.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" ?>
<?xml-stylesheet type='text/xsl' href='interface.xsl'?>
<interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
<name>0bootstrap</name>
<summary>create a native package that installs 0install and a program</summary>
Expand All @@ -13,23 +12,25 @@

<homepage>https://docs.0install.net/tools/0bootstrap/</homepage>

<feed-for interface="http://0install.net/tools/0bootstrap.xml"/>
<feed-for interface="http://0install.net/tools/0bootstrap-python.xml"/>

<group>
<command name="run" path="0bootstrap">
<runner interface="https://apps.0install.net/python/python.xml">
<version before="3"/>
<version before="3"/>
</runner>
</command>
<command name="test" path="tests/testbootstrap.py">
<runner interface="https://apps.0install.net/python/python.xml">
<version before="3"/>
<version before="3"/>
</runner>
</command>
<requires interface="http://0install.net/2007/interfaces/ZeroInstall.xml">
<requires interface="https://apps.0install.net/0install/0install-python.xml">
<version not-before="1.0"/>
<environment insert="" name="PYTHONPATH"/>
</requires>
<implementation id="." version="0.1-pre"/>

<!-- Use very high version number to treat local build as newer than any public version. -->
<implementation id="local" version="100-pre" stability="developer" local-path="."/>
</group>
</interface>
38 changes: 38 additions & 0 deletions 0bootstrap.xml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" ?>
<interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
<name>0bootstrap</name>
<summary>create a native package that installs 0install and a program</summary>
<description>
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.
</description>

<homepage>https://docs.0install.net/tools/0bootstrap/</homepage>

<feed-for interface="http://0install.net/tools/0bootstrap-python.xml"/>

<group>
<command name="run" path="0bootstrap">
<runner interface="https://apps.0install.net/python/python.xml">
<version before="3"/>
</runner>
</command>
<command name="test" path="tests/testbootstrap.py">
<runner interface="https://apps.0install.net/python/python.xml">
<version before="3"/>
</runner>
</command>
<requires interface="https://apps.0install.net/0install/0install-python.xml">
<version not-before="1.0"/>
<environment insert="" name="PYTHONPATH"/>
</requires>

<implementation version="{version}" local-path=".">
<manifest-digest/>
<archive href="0bootstrap-{version}.tar.bz2"/>
</implementation>
</group>
</interface>
42 changes: 42 additions & 0 deletions 0install.sh
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0c36376

Please sign in to comment.