feat: builder #3
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
on: | |
push: | |
branches: | |
- alpha | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.package_version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "18" | |
- name: Install dependencies | |
run: npm install | |
- name: Run start script | |
run: npm run start | |
- name: Get version from package.json | |
id: package_version | |
run: echo "::set-output name=version::$(jq -r '.version' package.json)" | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: index | |
path: index.json | |
check-release: | |
needs: build | |
runs-on: ubuntu-latest | |
outputs: | |
exists: ${{ steps.check_release.outputs.exists }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Check if release already exists | |
id: check_release | |
run: | | |
RELEASE_URL=$(curl -sH "Authorization: token ${{secrets.GITHUB_TOKEN}}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ needs.build.outputs.version }}) | |
if [[ "$RELEASE_URL" == *"\"url\": \"*"* ]]; then | |
echo "::set-output name=exists::true" | |
else | |
echo "::set-output name=exists::false" | |
fi | |
release: | |
needs: [build] | |
runs-on: ubuntu-latest | |
if: needs.build.outputs.version != '' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Create Release and Upload Assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: index.json | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |