-
Notifications
You must be signed in to change notification settings - Fork 23
142 lines (123 loc) · 4.47 KB
/
run-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Release New Version
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release type'
required: true
default: 'patch'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out develop
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
ref: develop
# https://stackoverflow.com/a/69634516
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- name: Setup Git user
uses: fregante/setup-git-user@v1
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- name: Tag release
run: npm version ${{ github.event.inputs.releaseType }}
# Sets new package version as ${{ env.PACKAGE_VERSION }}
- uses: nyaa8/package-version@v1
- name: Check out main
uses: actions/checkout@v3
with:
clean: false
fetch-depth: 0
persist-credentials: false
ref: main
- name: Sync branches
run: git merge -m "Merge ${{ github.event.inputs.releaseType }} commit" origin/develop
# Push merge commit back to main and trigger downstream workflows
# https://github.community/t/push-from-action-does-not-trigger-subsequent-action/16854/2
- uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
tags: true
branch: main
- run: PUBLIC_URL='./' npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Prepare Web Artifacts
run: zip farmhand-web -r build/*
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.PACKAGE_VERSION }}
release_name: ${{ env.PACKAGE_VERSION }}
draft: false
prerelease: false
- name: Upload Release Web Asset
id: upload_release_web_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the Create Release step above, referencing it's ID to get its outputs object, 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
asset_path: ./farmhand-web.zip
asset_name: farmhand-web-${{ env.PACKAGE_VERSION }}.zip
asset_content_type: application/zip
- run: node -e "console.log(require('./package.json').version)" > build/version.txt
- name: Publish itch.io build
uses: josephbmanley/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.ITCH_TOKEN }}
CHANNEL: html5
ITCH_GAME: Farmhand
ITCH_USER: jeremyckahn
PACKAGE: build
VERSION_FILE: build/version.txt
- run: |
PUBLIC_URL='/farmhand' npm run build
npm run doc
# https://github.com/marketplace/actions/deploy-to-github-pages
- name: Deploy to jeremyckahn.github.io/farmhand
uses: JamesIves/github-pages-deploy-action@3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: build
CLEAN: true
SINGLE_COMMIT: true
publish_native_build:
needs: release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
ref: main
# https://stackoverflow.com/a/69634516
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- name: 'Build and Release Electron App'
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: npm run build:native