New Release #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: New Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version' | |
type: string | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
- name: Get version # TODO(eeeqeee) add option to increment from current version | |
id: get-version | |
run: | | |
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | |
- name: Set git config | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Change version | |
if: steps.get-version.outputs.version != '' | |
run: | | |
TEMP_FILE=$(mktemp) | |
jq --arg v "${{ steps.get-version.outputs.version }}" '.version = $v' package.json > $TEMP_FILE | |
cp $TEMP_FILE package.json | |
git add . | |
git commit -m "${{ steps.get-version.outputs.version }}" | |
- name: Get commit msg | |
id: get-commit-msg | |
run: | | |
if [[ -z "${{ steps.get-version.outputs.version }}" ]]; then | |
echo "msg=deploy: $(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
else | |
echo "msg=deploy: version ${{ steps.get-version.outputs.version }} $(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
fi | |
- name: Yarn install | |
run: | | |
yarn install --immutable --immutable-cache | |
- name: Setup .env | |
run: | | |
printf '%s' "$ENVFILE" > apps/frontend/.env.local | |
env: | |
ENVFILE: ${{ secrets.ENVFILE }} | |
- name: Build genshin-optimizer | |
run: | | |
NX_URL_GITHUB_GO_CURRENT_VERSION="https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)" \ | |
yarn run nx run frontend:build-webpack:production | |
- name: Deploy to Github Pages | |
run: | | |
git fetch origin gh-pages --depth=1 | |
git worktree add ../gh-pages gh-pages --no-checkout | |
cp -rT dist/apps/frontend ../gh-pages | |
cd ../gh-pages | |
git add --all . | |
git commit -m "${{ steps.get-commit-msg.outputs.msg }}" | |
git push | |
- name: Push | |
run: | | |
git status | |
git push | |
- name: Make release | |
if: steps.get-version.outputs.version != '' | |
run: | | |
gh release create ${{ steps.get-version.outputs.version }} --generate-notes --target $(git rev-parse HEAD) | |
env: | |
GH_TOKEN: ${{ github.token }} |