From 742745070820c554c8d00f58ac2bc094f057b0c6 Mon Sep 17 00:00:00 2001 From: Eren Dogan Date: Mon, 13 Feb 2023 22:54:23 -0800 Subject: [PATCH] Make sure versions always have tags --- .github/workflows/sync.yml | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 7e374d50..b3ac219b 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -1,11 +1,16 @@ name: sync on: + push: + branches: + - dev workflow_call: secrets: WORKFLOW_ACCESS_TOKEN: required: true jobs: - sync_dev: + # This job synchronizes the 'dev' branch of OpenRAM repo with the current branch + sync_dev_no_version: + if: ${{ github.event_name == 'workflow_call' && github.repository == 'VLSIDA/PrivateRAM' }} runs-on: ubuntu-latest steps: - name: Checkout code @@ -23,3 +28,39 @@ jobs: git pull public-repo dev # Push the latest changes git push -u public-repo HEAD:dev + # This job makes sure that a version commit has a tag (manually bumped versions might have tags missing) + sync_dev_tag_check: + if: ${{ github.event_name == 'push' && github.repository == 'VLSIDA/PrivateRAM' && startsWith(github.event.head_commit.message, 'Bump version:') }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: ${{ secrets.WORKFLOW_ACCESS_TOKEN }} + - name: Compare version and tag + run: | + # Configure pusher account + git config --global user.name "mrg" + git config --global user.email "mrg@ucsc.edu" + # Add both repos + git remote add private-repo https://${{ secrets.WORKFLOW_ACCESS_TOKEN }}@github.com/VLSIDA/PrivateRAM.git + git remote add public-repo https://${{ secrets.WORKFLOW_ACCESS_TOKEN }}@github.com/VLSIDA/OpenRAM.git + # Read the version file + echo "LATEST_VERSION=v$(cat VERSION)" >> $GITHUB_ENV + # Read the tag name of the last commit + echo "HEAD_TAG=$(git describe --tags HEAD)" >> $GITHUB_ENV + - name: Make a new tag and push + if: ${{ env.LATEST_VERSION != env.HEAD_TAG }} + run: | + # Tag the commit + git tag ${{ env.LATEST_VERSION }} HEAD + # Push to private/dev + git pull private-repo dev + git push private-repo HEAD:dev --tags + # Push to public-repo/dev + git pull public-repo dev + git push public-repo HEAD:dev --tags + # Push to public/stable + git pull public-repo stable + git push public-repo HEAD:stable --tags