Skip to content

semver

semver #168

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
jobs:
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
outputs:
VERSION: ${{ steps.tag.outputs.VERSION }}
needs:
- 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
LAST_TAG=$(curl -sSL https://api.github.com/repos/alshdavid/http-server-rs/releases/latest | jq ".tag_name" | cut -d "." -f 3)
if [ "$LAST_TAG" = "" ]; then
LAST_TAG="0"
fi
declare -i var="$LAST_TAG"
var=$var+1
TAG="0.0.$var"
echo "Tag: ${NPM_VER}"
gh release create $NPM_VER --draft --notes "Automatically built binaries"
gh release edit $NPM_VER --title "πŸš€ Latest"
cd artifacts
for name in *; do
cd "${{ github.workspace }}/artifacts/${name}/release"
chmod +x ./*
tar -czvf ./${name}.tar.gz ./*
gh release upload $NPM_VER ${name}.tar.gz
done
gh release edit $NPM_VER --draft=false
echo "VERSION=$TAG" >> "$GITHUB_OUTPUT"
publish-npm-package:
name: "πŸ”„ Publish NPM Package"
runs-on: ubuntu-24.04
needs:
- publish-github-release
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: ${NPM_VER}"
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