Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: automate asset release #1852

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/asset-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Add Release Assets

on:
release:
types: [published]

jobs:
asset:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php: [ "5.4", "5.6", "7.0", "7.4" ]

name: Upload Release Assets
steps:
- uses: olegtarasov/get-tag@v2
id: tagName

- uses: octokit/request-action@v2.x
id: getLatestRelease
with:
route: GET /repos/:repository/releases/tags/:tag
repository: ${{ github.repository }}
tag: ${{ steps.tagName.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 10
max_attempts: 3
command: composer remove --dev cache/filesystem-adapter && composer install --no-dev --prefer-dist

- name: Create Archive
run: |
zip -r ${fileName} . &&
zip -d ${fileName} ".git*" &&
zip -d ${fileName} "tests*" &&
zip -d ${fileName} "examples*"
bshaffer marked this conversation as resolved.
Show resolved Hide resolved
env:
fileName: google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip

- name: Upload Release Archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{ fromJson(steps.getLatestRelease.outputs.data).upload_url }}
asset_path: ./google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip
asset_name: google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip
asset_content_type: application/zip