diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4094bbb168..c30753391c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,26 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 + # On push to master, increment patch version and create a new tag on release + - name: Increment patch version + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + run: | + git config user.name "nobody" + git config user.email "nobody@nowhere" + VERSION=$(git describe --tags --match 'v*' --abbrev=0 | xargs ./scripts/increment-semver.py) + git tag -a $VERSION -m $VERSION + echo "Generated new release version: $VERSION" + # GitHub treats the new tag as lightweight, so older tags will shadow the + # new tag. Recreate it as an annotated tag now so the version script picks + # it up properly. + - name: Annotate release tag + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + run: | + git config user.name "nobody" + git config user.email "nobody@nowhere" + VERSION=${GITHUB_REF/refs\/tags\//} + git tag -a -f $VERSION $VERSION -m $VERSION + echo "Recreated release tag: $VERSION" - name: Create source package run: | ./scripts/archive-source.sh src.tar @@ -280,7 +300,7 @@ jobs: path: xemu-macos-universal-${{ matrix.configuration }}.zip Release: - if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/xemu-v')) + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) runs-on: ubuntu-latest needs: [Ubuntu, macOSUniversal, Windows] steps: @@ -293,21 +313,15 @@ jobs: - name: Get release info run: | echo "XEMU_VERSION=$(cat XEMU_VERSION)" >> $GITHUB_ENV - if [[ $GITHUB_REF == refs/tags/* ]]; then - echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - else - # GitHub requires a tag to make a release, but this is not a tagged - # update. Generate a new tag. - echo "TAG_NAME=gh-release/$(cat XEMU_VERSION)" >> $GITHUB_ENV - fi - name: Publish release uses: softprops/action-gh-release@v1 with: - tag_name: ${{ env.TAG_NAME }} - name: ${{ env.XEMU_VERSION }} + tag_name: v${{ env.XEMU_VERSION }} + name: v${{ env.XEMU_VERSION }} prerelease: false draft: false files: | + dist/src.tar.gz/src.tar.gz dist/xemu-win-debug/xemu-win-debug.zip dist/xemu-win-release/xemu-win-release.zip dist/xemu-macos-universal-release/xemu-macos-universal-release.zip @@ -319,7 +333,7 @@ jobs: # package creation. PushToPPA: name: Push to PPA Snapshot Branch - if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/xemu-v')) + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) needs: [Ubuntu, macOSUniversal, Windows] runs-on: ubuntu-latest steps: diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 6482430d70..a2044943d2 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -76,7 +76,7 @@ done git rev-parse HEAD 2>/dev/null | tr -d '\n' > XEMU_COMMIT git symbolic-ref --short HEAD > XEMU_BRANCH -git describe --tags --match 'xemu-v*' | cut -c 7- | tr -d '\n' > XEMU_VERSION +git describe --tags --match 'v*' | cut -c 2- | tr -d '\n' > XEMU_VERSION tar -r --file "$tar_file" XEMU_COMMIT XEMU_BRANCH XEMU_VERSION exit 0 diff --git a/scripts/increment-semver.py b/scripts/increment-semver.py new file mode 100755 index 0000000000..431e41ea7e --- /dev/null +++ b/scripts/increment-semver.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +import argparse, re +ap = argparse.ArgumentParser() +ap.add_argument('semver', help='Input semver X.Y.Z') +args = ap.parse_args() +m = re.match(r'(?P[^\d]*)(?P\d+)\.(?P\d+)\.(?P\d+)', + args.semver) +assert m, 'Invalid version format' +print(m.group('pfx') + '.'.join([m.group('maj'), m.group('min'), + str(int(m.group('pat')) + 1)])) diff --git a/scripts/xemu-version.sh b/scripts/xemu-version.sh index 5fac211b45..95ed0cd2a6 100755 --- a/scripts/xemu-version.sh +++ b/scripts/xemu-version.sh @@ -21,7 +21,7 @@ XEMU_BRANCH=$( \ XEMU_VERSION=$( \ cd "$dir"; \ if test -e .git; then \ - git describe --tags --match 'xemu-v*' | cut -c 7- | tr -d '\n'; \ + git describe --tags --match 'v*' | cut -c 2- | tr -d '\n'; \ elif test -e XEMU_VERSION; then \ cat XEMU_VERSION; \ fi) @@ -36,15 +36,15 @@ get_version_dot () { XEMU_VERSION_MAJOR=$(get_version_dot 1) XEMU_VERSION_MINOR=$(get_version_dot 2) -XEMU_VERSION_MICRO=$(get_version_dot 3) -XEMU_VERSION_PATCH=$(get_version_field 2) +XEMU_VERSION_PATCH=$(get_version_dot 3) +XEMU_VERSION_COMMIT=$(get_version_field 2) cat <