From c906160f63140bba95d0f21f435a76e9d518eba3 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Sun, 11 Oct 2026 00:28:43 +0100 Subject: [PATCH] Take the version from git; release tags through GitHub Actions raz --version now prints git describe's name for the commit (made into build/version.inc by make), so a build past a release says so. ci.yml runs make check on every push to main; a pushed tag vX.Y.Z also becomes a release with a tarball of raz and lib/. Run by hand with a tag, it releases one already pushed, such as v0.3.0. --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..25bf715 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +# Checks every push to main. A pushed tag vX.Y.Z is checked too and +# becomes a GitHub release, with a tarball of raz and the lib/ it reads +# beside itself. Run by hand with a tag, it releases an older tag. +name: ci +on: + push: + branches: [main] + tags: ['v*'] + workflow_dispatch: + inputs: + tag: + description: the tag to release + required: true +permissions: + contents: write +jobs: + check: + runs-on: ubuntu-24.04 + env: + TAG: ${{ inputs.tag || (github.ref_type == 'tag' && github.ref_name) || '' }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || github.ref }} + fetch-depth: 0 # git describe needs the tags + - run: sudo apt-get update && sudo apt-get install -y fp-compiler + - run: make check + - name: release + if: env.TAG != '' + env: + GH_TOKEN: ${{ github.token }} + run: | + d=raz-${TAG#v}-linux-x86_64 + mkdir $d && cp -r raz lib LICENSE README.md $d + tar czf $d.tar.gz $d + gh release create "$TAG" $d.tar.gz --verify-tag \ + --title "raz ${TAG#v}" --notes "$(./raz --version)" diff --git a/CLAUDE.md b/CLAUDE.md index 8ac0191..1db280c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -56,10 +56,13 @@ compiler changes. Left for later at the owner's word: a rewrite of var parameters. -A release is an annotated tag `vX.Y.Z` on `main`, named after -`Version` in `src/raz.pas`, its message what `raz --version` prints -(`raz 0.3.0, report 2026-10.0`); `make check` passes first. v0.3.0 is -the first. +A release is an annotated tag `vX.Y.Z` on `main`, its message what +`raz --version` will print (`raz 0.3.0, report 2026-10.0`); `make +check` passes first. The compiler takes its version from `git +describe` (`build/version.inc`, made by `make`). Pushing the tag runs +`.github/workflows/ci.yml`, which checks it and makes the GitHub +release with a tarball of `raz` and `lib/`; it also checks every push +to `main`. v0.3.0 is the first. `test/libc` runs its programs over `lib/Sys.raz`, the C one, through a link in its `mods`. A test or example without `.expect` is only diff --git a/Makefile b/Makefile index 41a1c61..5c0a261 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,16 @@ FPC = fpc FPCFLAGS = -O2 -Mobjfpc -Sh- -vew -FUbuild -raz: src/*.pas | build - $(FPC) $(FPCFLAGS) -FE. -oraz src/raz.pas +raz: src/*.pas build/version.inc | build + $(FPC) $(FPCFLAGS) -Fibuild -FE. -oraz src/raz.pas + +# The version is git's name for the commit; the file changes only when +# that does, so raz isn't rebuilt for nothing. +build/version.inc: FORCE | build + @v=$$(git describe --tags --dirty 2>/dev/null || echo unknown); \ + v="'$${v#v}'"; echo "$$v" | cmp -s - $@ || echo "$$v" >$@ + +FORCE: units: src/*.pas | build for u in scan sym x64 link elf; do $(FPC) $(FPCFLAGS) src/$$u.pas || exit 1; done diff --git a/README.md b/README.md index ec633c1..8831fc6 100644 --- a/README.md +++ b/README.md @@ -132,10 +132,15 @@ ## Versions -The compiler says which version of the report it follows: +The compiler says its own version and that of the report it follows: $ ./raz --version raz 0.3.0, report 2026-10.0 + +The compiler's version is git's name for the commit it was built from: +`0.3.0` at the tag `v0.3.0`, `0.3.0-5-g38d29a8` five commits past it. +A release is a tag `vX.Y.Z` pushed to GitHub, which builds it, checks +it, and attaches `raz` with its `lib/` to the release. A version of the report is named by its month and a count; the report's last section says what each version changed. diff --git a/doc/compiler.md b/doc/compiler.md index 9aa57d0..095976f 100644 --- a/doc/compiler.md +++ b/doc/compiler.md @@ -15,7 +15,7 @@ | `src/parse.pas` | 1,816 | 1,685 | Declarations, statements, expressions, built-ins | | `src/link.pas` | 131 | 95 | Tree shaking, layout, patching | | `src/elf.pas` | 425 | 351 | Static and dynamic ELF, symbol table, line numbers | -| `src/raz.pas` | 214 | 169 | The command line, the entry points | +| `src/raz.pas` | 216 | 169 | The command line, the entry points | Every file opens with a comment that says what it is, what it depends on and what it leaves out. Read those first; they are the map. diff --git a/src/raz.pas b/src/raz.pas index db2a8a7..39f3ccb 100644 --- a/src/raz.pas +++ b/src/raz.pas @@ -28,7 +28,9 @@ uses math, BaseUnix, syscall, scan, sym, x64, gen, parse, link, elf; const - Version = '0.3.0'; + { what git describe says, made by make: 0.3.0 at the tag v0.3.0, + 0.3.0-5-g38d29a8 five commits past it } + Version = {$I version.inc}; Report = '2026-10.0'; { the version of doc/raz.md it follows } MemfdCreate = 319; { the system call; FPC 3.2.2 has no name for it } MfdCloexec = 1; { an ELF still executes: the kernel opens it first }