|
1 | 1 | # https://help.github.com/en/categories/automating-your-workflow-with-github-actions |
2 | 2 |
|
3 | 3 | on: |
4 | | - - pull_request |
5 | | - - push |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: '*' |
| 7 | + tags: 'v*' |
6 | 8 |
|
7 | 9 | name: CI |
8 | 10 |
|
@@ -138,6 +140,8 @@ jobs: |
138 | 140 |
|
139 | 141 | runs-on: ubuntu-latest |
140 | 142 |
|
| 143 | + if: startsWith( github.ref, 'refs/tags/v') == false |
| 144 | + |
141 | 145 | steps: |
142 | 146 | - name: Checkout |
143 | 147 | uses: actions/checkout@v2 |
@@ -182,3 +186,84 @@ jobs: |
182 | 186 | env: |
183 | 187 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
184 | 188 | run: bash <(curl -s https://codecov.io/bash) || true |
| 189 | + |
| 190 | + release: |
| 191 | + if: startsWith( github.ref, 'refs/tags/v') |
| 192 | + name: Create release |
| 193 | + |
| 194 | + runs-on: ubuntu-latest |
| 195 | + needs: ["coding-guidelines", "unit"] |
| 196 | + |
| 197 | + steps: |
| 198 | + - name: Checkout |
| 199 | + uses: actions/checkout@v2 |
| 200 | + |
| 201 | + - name: Install PHP with extensions |
| 202 | + uses: shivammathur/setup-php@v2 |
| 203 | + with: |
| 204 | + php-version: 7.2 |
| 205 | + extensions: json, mbstring, intl, apcu |
| 206 | + tools: composer, phive |
| 207 | + ini-values: assert.exception=1, zend.assertions=1, apc.enabled=1, apc.enable_cli=1 |
| 208 | + |
| 209 | + - name: Install dependencies with composer |
| 210 | + env: |
| 211 | + COMMERCETOOLS_CLIENT_ID: ${{ secrets.COMMERCETOOLS_CLIENT_ID }} |
| 212 | + COMMERCETOOLS_CLIENT_SECRET: ${{ secrets.COMMERCETOOLS_CLIENT_SECRET }} |
| 213 | + COMMERCETOOLS_PROJECT: ${{ secrets.COMMERCETOOLS_PROJECT }} |
| 214 | + run: composer install --no-ansi --no-interaction --no-progress --no-suggest --no-dev |
| 215 | + |
| 216 | + - name: Retrieve branch name |
| 217 | + id: branch_name |
| 218 | + run: | |
| 219 | + echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} |
| 220 | + echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} |
| 221 | + echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} |
| 222 | +
|
| 223 | + - name: Install box |
| 224 | + env: |
| 225 | + GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 226 | + run: phive install humbug/box --force-accept-unsigned |
| 227 | + |
| 228 | + - name: Compile phar |
| 229 | + run: tools/box compile |
| 230 | + |
| 231 | + - uses: actions/upload-artifact@v1 |
| 232 | + with: |
| 233 | + name: commercetools-php-sdk-${{ steps.branch_name.outputs.SOURCE_TAG }}.phar |
| 234 | + path: commercetools-php-sdk.phar |
| 235 | + |
| 236 | + - name: Read changeset |
| 237 | + id: changeset |
| 238 | + run: | |
| 239 | + CHANGESET=`php tools/extract_changelog.php` |
| 240 | + CHANGESET="${CHANGESET//'%'/'%25'}" |
| 241 | + CHANGESET="${CHANGESET//$'\n'/'%0A'}" |
| 242 | + CHANGESET="${CHANGESET//$'\r'/'%0D'}" |
| 243 | + echo "::set-output name=changes::$CHANGESET" |
| 244 | +
|
| 245 | + - name: Create Release |
| 246 | + id: create_release |
| 247 | + uses: actions/create-release@v1 |
| 248 | + env: |
| 249 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 250 | + with: |
| 251 | + tag_name: ${{ github.ref }} |
| 252 | + release_name: ${{ github.ref }} |
| 253 | + draft: true |
| 254 | + prerelease: false |
| 255 | + body: | |
| 256 | + ${{ steps.changeset.outputs.changes }} |
| 257 | +
|
| 258 | + - name: Upload Release Asset |
| 259 | + id: upload-release-asset |
| 260 | + uses: actions/upload-release-asset@v1 |
| 261 | + env: |
| 262 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 263 | + with: |
| 264 | + # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, |
| 265 | + # which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps |
| 266 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 267 | + asset_path: ./commercetools-php-sdk.phar |
| 268 | + asset_name: commercetools-php-sdk.phar |
| 269 | + asset_content_type: application/php-archive |
0 commit comments