Skip to content

Commit

Permalink
ci?
Browse files Browse the repository at this point in the history
  • Loading branch information
mikew committed Oct 6, 2024
1 parent acb3504 commit b7e1faf
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/main.yml
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')
3 changes: 3 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "0.1.0"
}
37 changes: 37 additions & 0 deletions script/deploy
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}"

0 comments on commit b7e1faf

Please sign in to comment.