| 
1 | 1 | name: 'Deploy / Create Release'  | 
2 | 2 | 
 
  | 
3 | 3 | on:  | 
4 |  | -  pull_request:  | 
5 |  | -    branches:  | 
6 |  | -      - master  | 
7 | 4 |   milestone:  | 
8 | 5 |     types: [ closed ]  | 
9 | 6 | 
 
  | 
 | 
12 | 9 |   ARTIFACT_ZIP: 'coblocks.zip'  | 
13 | 10 | 
 
  | 
14 | 11 | jobs:  | 
 | 12 | +  update:  | 
 | 13 | +    name: Update version  | 
 | 14 | +    runs-on: ubuntu-latest  | 
 | 15 | +    steps:  | 
 | 16 | +      - name: Checkout  | 
 | 17 | +        uses: actions/checkout@v3  | 
 | 18 | + | 
 | 19 | +      - name: Setup Node  | 
 | 20 | +        uses: actions/setup-node@v3  | 
 | 21 | +        with:  | 
 | 22 | +          node-version-file: '.nvmrc'  | 
 | 23 | +          cache: 'yarn'  | 
 | 24 | + | 
 | 25 | +      - name: Setup git user  | 
 | 26 | +        uses: godaddy-wordpress/setup-godaddy-git-user@v1  | 
 | 27 | + | 
 | 28 | +      # Yarn is still required on this project, so we need to make sure it is  | 
 | 29 | +      # installed globally.  | 
 | 30 | +      - name: Install yarn  | 
 | 31 | +        run: npm i -g yarn  | 
 | 32 | + | 
 | 33 | +      - name: Set version  | 
 | 34 | +        run: |  | 
 | 35 | +          echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV  | 
 | 36 | +
  | 
 | 37 | +      - name: Validate tag version  | 
 | 38 | +        run: |  | 
 | 39 | +          MATCH='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$'  | 
 | 40 | +          if ! [[ $NEW_TAG_VERSION =~ $MATCH ]]; then  | 
 | 41 | +              echo "::error::Milestone title does not match semver format: '$NEW_TAG_VERSION'"  | 
 | 42 | +              exit 1  | 
 | 43 | +          fi  | 
 | 44 | +
  | 
 | 45 | +      - name: Install dependencies  | 
 | 46 | +        run: |  | 
 | 47 | +          yarn install --immutable  | 
 | 48 | +
  | 
 | 49 | +      - name: Run version update  | 
 | 50 | +        run: yarn version --new-version $NEW_TAG_VERSION  | 
 | 51 | + | 
 | 52 | +      - name: Push changes  | 
 | 53 | +        run: |  | 
 | 54 | +          git add .  | 
 | 55 | +          git commit -m "Updating to version $NEW_TAG_VERSION" --no-verify  | 
 | 56 | +          git push  | 
 | 57 | +
  | 
15 | 58 |   build:  | 
16 | 59 |     name: Build  | 
17 | 60 |     uses: ./.github/workflows/deploy-create-artifact.yml  | 
 | 61 | +    needs: update  | 
 | 62 | + | 
 | 63 | +  tag:  | 
 | 64 | +    runs-on: ubuntu-latest  | 
 | 65 | +    name: Tag new version  | 
 | 66 | +    needs: update  | 
 | 67 | +    steps:  | 
 | 68 | +      - name: Checkout  | 
 | 69 | +        uses: actions/checkout@v3  | 
 | 70 | +        with:  | 
 | 71 | +          ref: ${{ github.event.repository.default_branch }}  | 
 | 72 | + | 
 | 73 | +      - name: Setup git user  | 
 | 74 | +        uses: godaddy-wordpress/setup-godaddy-git-user@v1  | 
 | 75 | + | 
 | 76 | +      - name: Set version  | 
 | 77 | +        run: |  | 
 | 78 | +          echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV  | 
 | 79 | +
  | 
 | 80 | +      - name: Publish new tag  | 
 | 81 | +        run: |  | 
 | 82 | +          git tag $NEW_TAG_VERSION  | 
 | 83 | +          git push origin $NEW_TAG_VERSION  | 
 | 84 | +
  | 
 | 85 | +  release:  | 
 | 86 | +    runs-on: ubuntu-latest  | 
 | 87 | +    name: Create new release  | 
 | 88 | +    needs: [ build, tag ]  | 
 | 89 | +    steps:  | 
 | 90 | +      - name: Checkout  | 
 | 91 | +        uses: actions/checkout@v3  | 
 | 92 | +        with:  | 
 | 93 | +          ref: ${{ github.event.repository.default_branch }}  | 
 | 94 | + | 
 | 95 | +      - name: Set release version  | 
 | 96 | +        run: |  | 
 | 97 | +          echo "RELEASE_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV  | 
 | 98 | +
  | 
 | 99 | +      - name: Create release  | 
 | 100 | +        env:  | 
 | 101 | +          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
 | 102 | +        run: |  | 
 | 103 | +          gh release create $RELEASE_VERSION -n "${{ github.event.milestone.description }}" -t "$RELEASE_VERSION"  | 
 | 104 | +
  | 
 | 105 | +      - name: Download theme  | 
 | 106 | +        uses: actions/download-artifact@v3  | 
 | 107 | +        with:  | 
 | 108 | +          name: ${{ env.ARTIFACT_NAME }}  | 
 | 109 | + | 
 | 110 | +      - name: Upload asset to release  | 
 | 111 | +        env:  | 
 | 112 | +          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
 | 113 | +        run: |  | 
 | 114 | +          gh release upload $RELEASE_VERSION ${{ env.ARTIFACT_ZIP }}  | 
0 commit comments