Update CI to do automatic tagging from version found in Makefile Issues: #489 Signed-off-by: Henner Zeller <hzeller@google.com>
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ab44d1..8242d83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml
@@ -78,3 +78,35 @@ env: OS: ${{ runner.os }} PLUGIN_NAME: ${{ matrix.plugin }} + + release-tagging: + name: Version Tagging + runs-on: ubuntu-20.04 + if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}} + permissions: + contents: write + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Tag with Makefile version if not already. + run: | + git config --local user.name "Development Bot" + git config --local user.email f4pga-dev@chipsalliance.org" + + # We want to tag whenever the version in the Makefile changes. + # So extract the hash of when the current version was entered. + read TAG_HASH TAG_VERSION <<<$(git annotate -l Makefile | sed 's/\(^[0-9A-Fa-f]\+\).*PLUGIN_VERSION\s\+=\s\+\([0-9]\+\.[0-9]\+\).*/\1 \2/p;d') + + echo "F4PGA Yosys Plugin Version v${TAG_VERSION} at hash ${TAG_HASH}" + + # If this is the first time we see this tag: apply. + if [ -z "$(git tag -l "v${TAG_VERSION}")" ]; then + git tag -a "v${TAG_VERSION}" ${TAG_HASH} -m "Update to v${TAG_VERSION}" + git push origin "v${TAG_VERSION}" + else + echo "Tag already applied" + fi