Skip to content

Create Release

Create Release #23

name: Create Release
on:
milestone:
types: [ closed ]
env:
ARTIFACT_NAME: 'go-theme'
ARTIFACT_ZIP: 'go.zip'
jobs:
update:
name: Update version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Setup git user
uses: godaddy-wordpress/setup-godaddy-git-user@v1
# Yarn is still required on this project, so we need to make sure it is
# installed globally.
- name: Install yarn
run: npm i -g yarn
- name: Set version
run: |
echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Validate tag version
run: |
MATCH='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$'
if ! [[ $NEW_TAG_VERSION =~ $MATCH ]]; then
echo "::error::Milestone title does not match semver format: '$NEW_TAG_VERSION'"
exit 1
fi
- name: Install dependencies
run: |
yarn install --immutable
- name: Run version update
run: yarn version --new-version $NEW_TAG_VERSION
- name: Push changes
run: |
git add .
git commit -m "Updating to version $NEW_TAG_VERSION" --no-verify
git push
build:
name: Build theme
uses: ./.github/workflows/create-artifact.yml
needs: update
tag:
runs-on: ubuntu-latest
name: Tag new version
needs: update
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
- name: Setup git user
uses: godaddy-wordpress/setup-godaddy-git-user@v1
- name: Set version
run: |
echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Publish new tag
run: |
git tag $NEW_TAG_VERSION
git push origin $NEW_TAG_VERSION
release:
runs-on: ubuntu-latest
name: Create new release
needs: [ build, tag ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
- name: Set release version
run: |
echo "RELEASE_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $RELEASE_VERSION -n "${{ github.event.milestone.description }}" -t "$RELEASE_VERSION"
- name: Download theme
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
- name: Upload asset to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload $RELEASE_VERSION ${{ env.ARTIFACT_ZIP }}