# HG changeset patch
# User Tina Müller <cpan2@tinita.de>
# Date 1590786436 -7200
#      Fri May 29 23:07:16 2020 +0200
# Node ID c03f83fb7b5bfb8fe899252b2f02750176615701
# Parent  f7cc251cdad48cad268b951debf877e07e299ac6
Add workflows for creating release tarballs and pyyaml testing

diff --git a/.github/workflows/dist.yaml b/.github/workflows/dist.yaml
new file mode 100644
--- /dev/null
+++ b/.github/workflows/dist.yaml
@@ -0,0 +1,29 @@
+name: dist
+
+on:
+  push:
+    branches: [ release/* ]
+
+jobs:
+  dist:
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - run: env | sort
+
+    - name: Get image
+      run: |
+        time docker pull yamlio/libyaml-dev
+        docker images | grep libyaml
+
+    - run: |
+        make -C packaging/docker libyaml-dist-ci
+    - run: |
+        ls -l packaging/docker/output
+
+    - uses: actions/upload-artifact@v2
+      with:
+        name: release
+        path: packaging/docker/output/yaml-0*
+
diff --git a/.github/workflows/pyyaml.yaml b/.github/workflows/pyyaml.yaml
new file mode 100644
--- /dev/null
+++ b/.github/workflows/pyyaml.yaml
@@ -0,0 +1,22 @@
+name: pyyaml-test
+
+on:
+  push:
+    branches: [ release/* ]
+
+jobs:
+  pyyaml-test:
+    strategy:
+      matrix:
+        python:
+        - python2
+        - python3
+
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - run: env | sort
+    - run: |
+        sudo apt-get install cython cython3
+    - run: |
+        make -C packaging/docker test-pyyaml-ci PYTHON=${{ matrix.python }}
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -28,7 +28,6 @@
 /configure
 stamp-h1
 !config/config.h.in
-/packaging/
 /tests/run-dumper
 /tests/run-emitter
 /tests/run-emitter-test-suite
diff --git a/Makefile.am b/Makefile.am
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,12 +43,12 @@
 	  git clone --branch $(LIBYAML_TEST_SUITE_RUN_BRANCH) $(LIBYAML_TEST_SUITE_RUN_REPO) $@
     endif
 
-packaging:
-	-git branch --track $@ origin/$@
-	git worktree add --force $@ $@
+docker-build:
+	make -C packaging/docker build
 
-docker-dist: packaging
-	make -C $</docker libyaml-dist
+docker-dist:
+	make -C packaging/docker libyaml-dist
 
-docker-test-pyyaml: packaging
-	make -C $</docker test-pyyaml
+docker-test-pyyaml:
+	make -C packaging/docker test-pyyaml PYTHON=python2
+	make -C packaging/docker test-pyyaml PYTHON=python3
diff --git a/packaging/README.md b/packaging/README.md
new file mode 100644
--- /dev/null
+++ b/packaging/README.md
@@ -0,0 +1,81 @@
+# How to make a release
+
+## Versioning
+
+Update libyaml version in:
+* announcement.msg
+* Changes
+* CMakeLists.txt
+  * `YAML_VERSION_MAJOR`, `YAML_VERSION_MINOR`, `YAML_VERSION_PATCH`
+* .appveyor.yml
+* configure.ac
+  * `YAML_MAJOR`, `YAML_MINOR`, `YAML_PATCH`, `YAML_RELEASE`, `YAML_CURRENT`, `YAML_REVISION`
+
+Commit and push everything to release/0.x.y
+
+## Test and Create Release archives
+
+This will create a docker image (libyaml-dev), test libyaml & pyyaml,
+and creat archives.
+
+Make sure you have a clean git repository (no changed files). The following
+process will clone your current git directory.
+
+### Run pyyaml tests on release branch
+
+Run
+
+    make docker-test-pyyaml
+
+It will run all libyaml tests, and run pyyaml tests (with python 2 & 3) on
+the current branch.
+
+### Create dist archives
+
+Run
+
+    make docker-dist
+
+
+It will create a docker image (libyaml-dev) and run `make dist` in the container
+to create a tarball written to packaging/docker/output.
+It will also create a zipfile.
+
+Unpack data for copying to dist branch:
+
+    cd packaging/docker/output
+    tar xvf yaml-0.x.y.tar.gz
+
+## Update dist branch
+
+    git worktree add dist dist
+    cd dist
+    rm -r *
+    cp -r ../packaging/docker/output/yaml-0.x.y/* .
+
+Check diffs and commit changes.
+
+    git tag dist-0.x.y
+    git push origin dist dist-0.x.y
+
+## Update master
+
+    git merge release/0.x.y
+    git tag -a 0.x.y
+    # <Editor opens>
+    # Paste the corresponding entry from the Changes file
+    # Look at an earlier release for how it should look like:
+    #   git show 0.2.3
+    git push origin master 0.x.y
+
+## Update pyyaml.org
+
+* Put the resulting tarball & zip in pyyaml.org/download/libyaml
+* Update wiki/LibYAML.md with release number and date
+* Update wiki/index.md
+
+Run
+
+    make update
+
+Check diffs and commit and push.
diff --git a/packaging/docker/.gitignore b/packaging/docker/.gitignore
new file mode 100644
--- /dev/null
+++ b/packaging/docker/.gitignore
@@ -0,0 +1,2 @@
+output/*
+!Makefile
diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile
new file mode 100644
--- /dev/null
+++ b/packaging/docker/Dockerfile
@@ -0,0 +1,35 @@
+FROM ubuntu:18.04
+
+RUN apt-get update && \
+    apt-get install -y \
+    build-essential \
+    doxygen \
+    less \
+    cmake \
+    python \
+    cython \
+    python3 \
+    cython3 \
+    flex \
+    bison \
+    automake \
+    libtool \
+    curl \
+    vim \
+    git \
+    zip \
+   && true
+
+# http://www.doxygen.nl/manual/install.html
+
+RUN curl https://sourceforge.net/projects/doxygen/files/rel-1.8.14/doxygen-1.8.14.src.tar.gz/download \
+    -L -o /doxygen-1.8.14.src.tar.gz && \
+    cd / && \
+    tar -xvf doxygen-1.8.14.src.tar.gz && \
+    cd doxygen-1.8.14 && \
+    mkdir build && \
+    cd build && \
+    cmake -G "Unix Makefiles" .. && \
+    make && \
+    make install
+
diff --git a/packaging/docker/Makefile b/packaging/docker/Makefile
new file mode 100644
--- /dev/null
+++ b/packaging/docker/Makefile
@@ -0,0 +1,26 @@
+
+build:
+	docker build -t yamlio/libyaml-dev .
+
+run: build
+	docker run -it --rm yamlio/libyaml-dev bash
+
+prepare-git:
+	rm -rf output/libyaml.git
+	git clone ../../.git output/libyaml.git
+
+libyaml-dist: libyaml-dist-ci
+
+libyaml-dist-ci: prepare-git
+	docker run --rm -u $$(id -u) -v$$PWD/output:/output -v$$PWD/scripts:/scripts yamlio/libyaml-dev /scripts/libyaml-dist.sh
+
+
+test-pyyaml: prepare-git
+	docker run --rm --env PYTHON -v$$PWD/output:/output -v$$PWD/scripts:/scripts yamlio/libyaml-dev /scripts/libyaml-test-pyyaml.sh
+
+test-pyyaml-ci: prepare-git
+	OUTPUT=$$PWD/output ./scripts/libyaml-test-pyyaml.sh
+
+clean:
+	rm -rf output/libyaml.git
+	rm -rf output/yaml-*.*
diff --git a/packaging/docker/output/README b/packaging/docker/output/README
new file mode 100644
--- /dev/null
+++ b/packaging/docker/output/README
@@ -0,0 +1,1 @@
+Output directory for build files createdd by docker
diff --git a/packaging/docker/scripts/libyaml-dist.sh b/packaging/docker/scripts/libyaml-dist.sh
new file mode 100755
--- /dev/null
+++ b/packaging/docker/scripts/libyaml-dist.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+set -ex
+
+cp -r /output/libyaml.git /tmp/
+cd /tmp/libyaml.git
+./bootstrap
+./configure
+make dist
+
+# get the tarball filename
+tarballs=(yaml-*.tar.gz)
+tarball=${tarballs[0]:?}
+dirname=${tarball/.tar.gz/}
+
+# Copy to output dir
+cp "$tarball" /output
+
+# Create zip archive
+cd /tmp
+cp "/output/$tarball" .
+tar xvf "$tarball"
+zip -r "/output/$dirname.zip" "$dirname"
diff --git a/packaging/docker/scripts/libyaml-test-pyyaml.sh b/packaging/docker/scripts/libyaml-test-pyyaml.sh
new file mode 100755
--- /dev/null
+++ b/packaging/docker/scripts/libyaml-test-pyyaml.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+OUTPUT="${OUTPUT:-/output}"
+set -ex
+
+$PYTHON --version
+
+cp -r $OUTPUT/libyaml.git /tmp/
+cd /tmp/libyaml.git
+
+./bootstrap
+./configure
+make test
+sudo make install
+sudo ldconfig
+
+git clone https://github.com/yaml/pyyaml.git /tmp/pyyaml
+cd /tmp/pyyaml
+$PYTHON setup.py test
+
+echo "$PYTHON pyyaml successful"