Skip to content

Tidy up the http1_server abstraction #164

Tidy up the http1_server abstraction

Tidy up the http1_server abstraction #164

Workflow file for this run

name: Release
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
on:
push:
branches:
- "main"
env:
PROJECT_NAME: http-server
JUST_VERSION: "1.36.0"
jobs:
vars:
name: "πŸ“‹ Generate Variables"
runs-on: ubuntu-24.04
outputs:
NPM_VER: ${{ steps.tag.outputs.NPM_VER }}
GH_TAG: ${{ steps.tag.outputs.GH_TAG }}
steps:
- run: eval $(curl -sSf sh.davidalsh.com/nodejs.sh | sh)
- id: tag
run: |
declare -i var=$(npm info http-server-rs version | cut -d "." -f 3)
var=$var+1
NPM_VER="0.0.$var"
GH_TAG="$(date -u +"v%Y.%m.%d.%H%M").${GITHUB_SHA::4}"
echo NPM_VER: $NPM_VER
echo GH_TAG:$GH_TAG
echo "NPM_VER=$NPM_VER" >> "$GITHUB_OUTPUT"
echo "GH_TAG=$GH_TAG" >> "$GITHUB_OUTPUT"
test:
name: πŸ§ͺ Test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: eval $(curl -sSf sh.davidalsh.com/just.sh | sh)
- run: eval $(curl -sSf sh.davidalsh.com/rust.sh | sh)
- run: just test
format:
name: πŸ“ Format
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: eval $(curl -sSf sh.davidalsh.com/just.sh | sh)
- run: eval $(curl -sSf sh.davidalsh.com/rust.sh | sh)
- run: just fmt
lint:
name: πŸ€“ Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: eval $(curl -sSf sh.davidalsh.com/just.sh | sh)
- run: eval $(curl -sSf sh.davidalsh.com/rust.sh | sh)
- run: just lint
build:
strategy:
matrix:
config:
- name: πŸ₯ Linux AMD64
os: linux
arch: amd64
runner: ubuntu-24.04
run: rustup target add x86_64-unknown-linux-musl
- name: πŸ₯ Linux ARM64
os: linux
arch: arm64
runner: ubuntu-24.04-arm
run: rustup target add aarch64-unknown-linux-musl
- name: 🍎 MacOS AMD64
os: macos
arch: amd64
runner: macos-13
- name: 🍎 MacOS ARM64
os: macos
arch: arm64
runner: macos-15
- name: 🟦 Windows AMD64
os: windows
arch: amd64
runner: windows-latest
- name: 🟦 Windows ARM64
os: windows
arch: arm64
runner: windows-latest
run: rustup target add aarch64-pc-windows-msvc
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.runner }}
steps:
- uses: actions/checkout@v4
- run: eval $(curl -sSf sh.davidalsh.com/just.sh | sh)
- run: eval $(curl -sSf sh.davidalsh.com/rust.sh | sh)
- if: matrix.config.run
run: ${{ matrix.config.run }}
- env:
os: "${{ matrix.config.os }}"
arch: "${{ matrix.config.arch }}"
profile: "release"
run: just build
- uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.config.os }}-${{ matrix.config.arch }}
path: ${{ github.workspace }}/target/${{ matrix.config.os }}-${{ matrix.config.arch }}/**/*
if-no-files-found: error
retention-days: 1
publish-github-release:
name: "πŸ”„ Publish Github Release"
runs-on: ubuntu-24.04
needs:
- vars
- test
- format
- lint
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with: { path: artifacts }
- name: Publish` Github Release
env:
GH_TAG: ${{needs.vars.outputs.GH_TAG}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
echo "Tag: ${GH_TAG}"
gh release create $GH_TAG --draft --notes "Automatically built binaries"
gh release edit $GH_TAG --title "πŸš€ Latest"
cd artifacts
for name in *; do
cd "${{ github.workspace }}/artifacts/${name}/release"
chmod +x ./*
tar -czvf ./${name}.tar.gz ./*
gh release upload $GH_TAG ${name}.tar.gz
done
gh release edit $GH_TAG --draft=false
publish-npm-package:
name: "πŸ”„ Publish NPM Package"
runs-on: ubuntu-24.04
needs:
- vars
- test
- format
- lint
- build
steps:
- uses: actions/checkout@v4
- run: eval $(curl -sSf sh.davidalsh.com/nodejs.sh | sh)
- env:
GH_TAG: ${{needs.vars.outputs.GH_TAG}}
NPM_VER: ${{needs.vars.outputs.NPM_VER}}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> $HOME/.npmrc
echo "GH_TAG: ${GH_TAG}"
echo "NPM_VER: ${NPM_VER}"
node .github/scripts/string-replace.mjs ./npm/package.json "0.0.0-local" "$NPM_VER"
cp ./README.md ./npm/README.md
cd npm
echo "$GH_TAG" > tag
npm publish --access=public