|
| 1 | +name: Release workflow |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + pull_request: |
| 7 | + branches: [master] |
| 8 | + |
| 9 | +env: |
| 10 | + GHR_PROJECT_REPONAME: ui5-language-assistant |
| 11 | + GHR_PROJECT_USERNAME: SAP |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + if: github.ref == 'refs/heads/master' # to filter out tag pushes |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + os: [ubuntu-latest] |
| 19 | + node-version: [14.x, 16.x, 18.x] |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - name: Checkout code repository |
| 23 | + uses: actions/checkout@v3 |
| 24 | + with: |
| 25 | + fetch-depth: 0 # will fetch all history |
| 26 | + - name: Run install |
| 27 | + uses: borales/actions-yarn@v4 |
| 28 | + with: |
| 29 | + cmd: install # will run `yarn install` command |
| 30 | + - name: Run build |
| 31 | + uses: borales/actions-yarn@v4 |
| 32 | + with: |
| 33 | + cmd: ci # will run `yarn run ci` command |
| 34 | + |
| 35 | + - name: Upload vsix artifact |
| 36 | + uses: actions/upload-artifact@v3 |
| 37 | + with: |
| 38 | + name: vscode-extension-file |
| 39 | + path: ./packages/vscode-ui5-language-assistant/vscode-ui5-language-assistant*.vsix |
| 40 | + retention-days: 1 |
| 41 | + if-no-files-found: error |
| 42 | + |
| 43 | + compliance: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v3 |
| 47 | + - name: REUSE Compliance Check |
| 48 | + uses: fsfe/reuse-action@v1 |
| 49 | + with: |
| 50 | + args: --include-submodules lint |
| 51 | + |
| 52 | + version: |
| 53 | + # Run version job only on pushes to the main branch. The job depends on completion of the build job. |
| 54 | + if: github.repository == 'SAP/ui5-language-assistant' && github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: [build, compliance] |
| 57 | + outputs: |
| 58 | + changes: ${{ steps.changesetVersion.outputs.changes }} # map step output to job output |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Checkout code repository |
| 62 | + uses: actions/checkout@v3 |
| 63 | + with: |
| 64 | + fetch-depth: 0 |
| 65 | + token: ${{ secrets.ACCESS_PAT }} # needed to auto trigger release job |
| 66 | + - name: Setup node |
| 67 | + uses: actions/setup-node@v3 |
| 68 | + with: |
| 69 | + node-version: 14 |
| 70 | + |
| 71 | + - name: Run install |
| 72 | + uses: borales/actions-yarn@v4 |
| 73 | + with: |
| 74 | + cmd: install # will run `yarn install` command |
| 75 | + |
| 76 | + - name: Apply changesets |
| 77 | + id: changesetVersion |
| 78 | + run: | |
| 79 | + echo ::set-output name=changes::$(npm run ci:version 2>&1 | grep -q 'No unreleased changesets found' && echo 'false' || echo 'true') |
| 80 | + git status |
| 81 | +
|
| 82 | + # Get new version number |
| 83 | + - name: get-npm-version |
| 84 | + id: package-version |
| 85 | + uses: martinbeentjes/npm-get-version-action@main |
| 86 | + with: |
| 87 | + path: ./packages/vscode-ui5-language-assistant |
| 88 | + |
| 89 | + # Apply changes and create version tag |
| 90 | + - name: Commit and push changes |
| 91 | + if: steps.changesetVersion.outputs.changes == 'true' |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }} |
| 94 | + run: | |
| 95 | + echo ${{ steps.package-version.outputs.current-version}} |
| 96 | + git config user.name github-actions |
| 97 | + git config user.email [email protected] |
| 98 | + git status |
| 99 | + git add -A |
| 100 | + git status |
| 101 | + git commit -m "chore: apply latest changesets" --no-verify || echo "No changesets found" |
| 102 | + git tag -a "v${{ steps.package-version.outputs.current-version}}" -m "v${{ steps.package-version.outputs.current-version}} release" |
| 103 | + git log --pretty=oneline | head -n 10 |
| 104 | + git push --follow-tags |
| 105 | +
|
| 106 | + release: |
| 107 | + if: github.repository == 'SAP/ui5-language-assistant' && github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.version.outputs.changes == 'false' |
| 108 | + runs-on: [ubuntu-latest] |
| 109 | + needs: version |
| 110 | + steps: |
| 111 | + - name: Checkout code repository |
| 112 | + uses: actions/checkout@v3 |
| 113 | + with: |
| 114 | + fetch-depth: 0 |
| 115 | + |
| 116 | + # Download vsix artifact |
| 117 | + - name: 'make folder' |
| 118 | + run: mkdir ./artifacts |
| 119 | + - name: Download artifact |
| 120 | + uses: actions/download-artifact@v3 |
| 121 | + with: |
| 122 | + name: vscode-extension-file |
| 123 | + path: ./artifacts |
| 124 | + |
| 125 | + - name: 'check artifacts' |
| 126 | + run: ls ./artifacts -la |
| 127 | + |
| 128 | + # Get new version number |
| 129 | + - name: get-npm-version |
| 130 | + id: package-version |
| 131 | + uses: martinbeentjes/npm-get-version-action@main |
| 132 | + with: |
| 133 | + path: ./packages/vscode-ui5-language-assistant |
| 134 | + |
| 135 | + # Publish on GitHub |
| 136 | + - name: Create Release |
| 137 | + env: |
| 138 | + GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }} # A personal access token |
| 139 | + CURRENT_RELEASE_VERSION: ${{steps.package-version.outputs.current-version}} |
| 140 | + uses: ncipollo/release-action@v1 |
| 141 | + with: |
| 142 | + allowUpdates: true |
| 143 | + draft: false |
| 144 | + prerelease: false |
| 145 | + name: Release v${{env.CURRENT_RELEASE_VERSION}} |
| 146 | + tag: v${{env.CURRENT_RELEASE_VERSION}} |
| 147 | + owner: ${{env.GHR_PROJECT_USERNAME}} |
| 148 | + repo: ${{env.GHR_PROJECT_REPONAME}} |
| 149 | + artifacts: './artifacts/*-${{env.CURRENT_RELEASE_VERSION}}.vsix' |
0 commit comments