Skip to content

Instantly share code, notes, and snippets.

@claytoncollie
Created June 15, 2021 18:59
Show Gist options
  • Select an option

  • Save claytoncollie/d2610767c6b6fcaf87afbb89885df364 to your computer and use it in GitHub Desktop.

Select an option

Save claytoncollie/d2610767c6b6fcaf87afbb89885df364 to your computer and use it in GitHub Desktop.
Tag, build, release
name: Tag, Build, Release
on:
push:
# Run when tag is pushed to repository
# Pattern matching for semantic version number
# https://semver.org/#summary
tags:
- '*.*.*'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Check out repository
- name: Checkout code
uses: actions/checkout@v2
# Create our release with tag as name
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: Release for version ${{ github.ref }}
draft: false
prerelease: false
# Run Composer to build dist version
# Create empty directory to later house our ZIP archive
- name: Build
run: |
rm -rf vendor
composer config -g github-oauth.github.com ${{ secrets.CONTENT_PILOT_USER_TOKEN }}
composer install --no-dev --no-cache --no-interaction
git reset --hard
mkdir ${{ github.event.repository.name}}
rsync -rv --exclude=${{ github.event.repository.name}} --exclude=.* --exclude=stylelint.config.js --exclude=webpack.mix.js --exclude=phpcs.xml --exclude=codeception.dist.yml --exclude=.git --exclude=.github --exclude=.vscode --exclude=node_modules --exclude=tests . ${{ github.event.repository.name}}
env:
ACF_PRO_KEY: ${{ secrets.ACF_PRO_KEY }}
# Create ZIP archive of dist version
# Located in the /build directory we created earlier
- name: Create artifact
uses: montudor/[email protected]
with:
args: zip -qq -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name}}
# Upload our ZIP archive as an asset to the release we created earlier
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.event.repository.name }}.zip
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment