3 Commits

Author SHA1 Message Date
Stephan
030cc2b97d wip 2021-06-04 11:50:43 +02:00
Stephan
178d291e4d wip 2021-06-04 11:50:34 +02:00
Stephan
8e58b6290c wip 2021-06-04 11:50:15 +02:00

View File

@@ -23,66 +23,28 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 2 # get parent
- name: Report - name: Report
shell: bash shell: bash
run: | run: |
set +e
git log --graph --pretty=format':%h%%d %s %an, %ar' | head -n 5 git log --graph --pretty=format':%h%%d %s %an, %ar' | head -n 5
echo "--" if [ "${{ github.ref }}#refs/heads/" != "${{ github.ref }}" ]; then
REF="${{ github.ref }}" # a commit, not a tag
BRANCH=${REF#refs/heads/} echo "COMMIT"
BRANCH="${{ github.ref }}#refs/heads/"
if [ "$BRANCH" != "$REF" ]; then git fetch origin wip-$BRANCH:wip-$BRANCH
VERSION=${BRANCH#release/} if [ $? -ne 0 ]; then
if [ "$VERSION" != "$BRANCH" ]; then echo "TAG NOT FOUND"
echo "Triggered by commit in version $VERSION release branch $BRANCH"
git fetch origin refs/tags/v$VERSION:refs/tags/v$VERSION
if [ $? -ne 0 ]; then
echo "Tag v$VERSION does not exist"
else
TAGSHA=$(git rev-parse v$VERSION)
echo "FOUND TAG $TAGSHA"
if [ "$TAGSHA" != "${{ github.sha }}" ]; then
echo "::error::TAG v$VERSION exists on another commit (${{ github.sha }}) : error"
exit 1
else
echo "Tag v$VERSION exists on this commit: nothing to do here"
fi
fi
else else
echo "::error::Triggered by commit in non-release branch $BRANCH: error" TAGSHA=$(git rev-parse wip-$BRANCH)
exit 1 echo "FOUND TAG $TAGSHA"
if [ "$TAGSHA" != "${{ github.sha }}" ]; then
echo "BAD TAG"
else
echo "GOOD TAG"
fi
fi fi
exit 0 else
# a tag?
echo "TAG"
fi fi
HZTAG=${REF#refs/tags/}
if [ "$HZTAG" != "$REF" ]; then
HZVERSION=${HZTAG#v}
if [ "$HZVERSION" != "$HZTAG" ]; then # it is a version tag
echo "Triggered by version tag $HZTAG"
git fetch origin refs/heads/release/$HZVERSION:refs/heads/release/$HZVERSION
if [ $? -ne 0 ]; then
echo "::error::Branch release/$HZVERSION does not exist"
exit 1
else
HZBRANCHSHA=$(git rev-parse release/$HZVERSION)
HZPARENTSHA=$(git rev-parse $HZTAG^1)
if [ "$HZBRANCHSHA" != "$HZPARENTSHA" ]; then
echo "::error::Tag parent is not HEAD of release/$HZVERSION but $HZPARENTSHA"
exit 1
else
echo "Tag parent is HEAD of release/$HZVERSION, proceed"
fi
fi
else
echo "::error::Triggered by non-version tag $HZTAG"
exit 1
fi
exit 0
fi
echo "::error::I am confused"
exit 1