-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: main | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "**" | ||
tags-ignore: | ||
- "**" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- ubuntu-20.04 | ||
|
||
runs-on: ${{ matrix.platform }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Bumping the version in each build is easier than setting up a new job | ||
# and transferring over artifacts. | ||
# We do it again in the deploy job and then commit that along with other | ||
# files generated during that phase. | ||
- run: npx commit-and-tag-version --skip.commit --skip.tag | ||
shell: bash | ||
if: endsWith(github.ref, '/main') | ||
|
||
- run: ./script/build | ||
shell: bash | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: wadpunk-${{ matrix.platform }}-${{ runner.arch }} | ||
retention-days: 7 | ||
path: | | ||
dist/* | ||
deploy: | ||
needs: | ||
- build | ||
|
||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
if: endsWith(github.ref, '/main') | ||
|
||
# prepare-env: Push as github bot. | ||
# https://github.community/t/github-actions-bot-email-address/17204/5 | ||
- name: Prep for git push | ||
run: | | ||
git config --local user.name "github-actions[bot]" | ||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
shell: bash | ||
if: endsWith(github.ref, '/main') | ||
|
||
- uses: actions/download-artifact@v4 | ||
if: endsWith(github.ref, '/main') | ||
|
||
# This is CI specific, artifacts don't seem to be stored with a helpful | ||
# path. | ||
- run: | | ||
mkdir -p dist | ||
cp -rl wadpunk-ubuntu-20.04-X64/* dist | ||
shell: bash | ||
if: endsWith(github.ref, '/main') | ||
- run: ./script/deploy | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
if: endsWith(github.ref, '/main') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": "0.1.0" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# Skipping commit because we need to generate some more files, and committing | ||
# them all at once is a little nicer. | ||
# Skipping tag for similar reasons, since we're committing later we can just tag | ||
# then. | ||
npx commit-and-tag-version --skip.commit --skip.tag | ||
|
||
# Grab the release name. | ||
RELEASE_TAG="v$(cat manifest.json | jq --raw-output .version)" | ||
|
||
# Prepare the release. | ||
gh release create --generate-notes --draft=true "${RELEASE_TAG}" | ||
|
||
# Upload artifacts. | ||
gh release upload "${RELEASE_TAG}" dist/* | ||
|
||
# Need to mark it as not draft, otherwise the URLS to assets aren't accessible. | ||
# TODO We could just replace them ourselves, we know the path will be | ||
# `/${RELEASE_TAG}/...` | ||
gh release edit --draft=false "${RELEASE_TAG}" | ||
|
||
# Commit and tag release. | ||
git add \ | ||
manifest.json \ | ||
CHANGELOG.md | ||
git commit --message "[skip ci] Release ${RELEASE_TAG}" | ||
git tag "${RELEASE_TAG}" | ||
|
||
# Get the SHA of the latest commit | ||
COMMIT_SHA=$(git rev-parse HEAD) | ||
git push --force origin "${RELEASE_TAG}" | ||
# git push origin HEAD | ||
|
||
# Update the target for the release. | ||
gh release edit "--target=${COMMIT_SHA}" "${RELEASE_TAG}" |