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.
| @@ -0,0 +1,37 @@ | ||
| 1 | +# Checks every push to main. A pushed tag vX.Y.Z is checked too and | |
| 2 | +# becomes a GitHub release, with a tarball of raz and the lib/ it reads | |
| 3 | +# beside itself. Run by hand with a tag, it releases an older tag. | |
| 4 | +name: ci | |
| 5 | +on: | |
| 6 | + push: | |
| 7 | + branches: [main] | |
| 8 | + tags: ['v*'] | |
| 9 | + workflow_dispatch: | |
| 10 | + inputs: | |
| 11 | + tag: | |
| 12 | + description: the tag to release | |
| 13 | + required: true | |
| 14 | +permissions: | |
| 15 | + contents: write | |
| 16 | +jobs: | |
| 17 | + check: | |
| 18 | + runs-on: ubuntu-24.04 | |
| 19 | + env: | |
| 20 | + TAG: ${{ inputs.tag || (github.ref_type == 'tag' && github.ref_name) || '' }} | |
| 21 | + steps: | |
| 22 | + - uses: actions/checkout@v4 | |
| 23 | + with: | |
| 24 | + ref: ${{ inputs.tag || github.ref }} | |
| 25 | + fetch-depth: 0 # git describe needs the tags | |
| 26 | + - run: sudo apt-get update && sudo apt-get install -y fp-compiler | |
| 27 | + - run: make check | |
| 28 | + - name: release | |
| 29 | + if: env.TAG != '' | |
| 30 | + env: | |
| 31 | + GH_TOKEN: ${{ github.token }} | |
| 32 | + run: | | |
| 33 | + d=raz-${TAG#v}-linux-x86_64 | |
| 34 | + mkdir $d && cp -r raz lib LICENSE README.md $d | |
| 35 | + tar czf $d.tar.gz $d | |
| 36 | + gh release create "$TAG" $d.tar.gz --verify-tag \ | |
| 37 | + --title "raz ${TAG#v}" --notes "$(./raz --version)" |
| @@ -56,10 +56,13 @@ | ||
| 56 | 56 | compiler changes. Left for later at the owner's word: a rewrite of |
| 57 | 57 | var parameters. |
| 58 | 58 | |
| 59 | -A release is an annotated tag `vX.Y.Z` on `main`, named after | |
| 60 | -`Version` in `src/raz.pas`, its message what `raz --version` prints | |
| 61 | -(`raz 0.3.0, report 2026-10.0`); `make check` passes first. v0.3.0 is | |
| 62 | -the first. | |
| 59 | +A release is an annotated tag `vX.Y.Z` on `main`, its message what | |
| 60 | +`raz --version` will print (`raz 0.3.0, report 2026-10.0`); `make | |
| 61 | +check` passes first. The compiler takes its version from `git | |
| 62 | +describe` (`build/version.inc`, made by `make`). Pushing the tag runs | |
| 63 | +`.github/workflows/ci.yml`, which checks it and makes the GitHub | |
| 64 | +release with a tarball of `raz` and `lib/`; it also checks every push | |
| 65 | +to `main`. v0.3.0 is the first. | |
| 63 | 66 | |
| 64 | 67 | `test/libc` runs its programs over `lib/Sys.raz`, the C one, through |
| 65 | 68 | a link in its `mods`. A test or example without `.expect` is only |
| @@ -4,8 +4,16 @@ | ||
| 4 | 4 | FPC = fpc |
| 5 | 5 | FPCFLAGS = -O2 -Mobjfpc -Sh- -vew -FUbuild |
| 6 | 6 | |
| 7 | -raz: src/*.pas | build | |
| 8 | - $(FPC) $(FPCFLAGS) -FE. -oraz src/raz.pas | |
| 7 | +raz: src/*.pas build/version.inc | build | |
| 8 | + $(FPC) $(FPCFLAGS) -Fibuild -FE. -oraz src/raz.pas | |
| 9 | + | |
| 10 | +# The version is git's name for the commit; the file changes only when | |
| 11 | +# that does, so raz isn't rebuilt for nothing. | |
| 12 | +build/version.inc: FORCE | build | |
| 13 | + @v=$$(git describe --tags --dirty 2>/dev/null || echo unknown); \ | |
| 14 | + v="'$${v#v}'"; echo "$$v" | cmp -s - $@ || echo "$$v" >$@ | |
| 15 | + | |
| 16 | +FORCE: | |
| 9 | 17 | |
| 10 | 18 | units: src/*.pas | build |
| 11 | 19 | for u in scan sym x64 link elf; do $(FPC) $(FPCFLAGS) src/$$u.pas || exit 1; done |
| @@ -132,10 +132,15 @@ | ||
| 132 | 132 | |
| 133 | 133 | ## Versions |
| 134 | 134 | |
| 135 | -The compiler says which version of the report it follows: | |
| 135 | +The compiler says its own version and that of the report it follows: | |
| 136 | 136 | |
| 137 | 137 | $ ./raz --version |
| 138 | 138 | raz 0.3.0, report 2026-10.0 |
| 139 | + | |
| 140 | +The compiler's version is git's name for the commit it was built from: | |
| 141 | +`0.3.0` at the tag `v0.3.0`, `0.3.0-5-g38d29a8` five commits past it. | |
| 142 | +A release is a tag `vX.Y.Z` pushed to GitHub, which builds it, checks | |
| 143 | +it, and attaches `raz` with its `lib/` to the release. | |
| 139 | 144 | |
| 140 | 145 | A version of the report is named by its month and a count; the report's |
| 141 | 146 | last section says what each version changed. |
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | | `src/parse.pas` | 1,816 | 1,685 | Declarations, statements, expressions, built-ins | |
| 16 | 16 | | `src/link.pas` | 131 | 95 | Tree shaking, layout, patching | |
| 17 | 17 | | `src/elf.pas` | 425 | 351 | Static and dynamic ELF, symbol table, line numbers | |
| 18 | -| `src/raz.pas` | 214 | 169 | The command line, the entry points | | |
| 18 | +| `src/raz.pas` | 216 | 169 | The command line, the entry points | | |
| 19 | 19 | |
| 20 | 20 | Every file opens with a comment that says what it is, what it depends |
| 21 | 21 | on and what it leaves out. Read those first; they are the map. |
| @@ -28,7 +28,9 @@ | ||
| 28 | 28 | uses math, BaseUnix, syscall, scan, sym, x64, gen, parse, link, elf; |
| 29 | 29 | |
| 30 | 30 | const |
| 31 | - Version = '0.3.0'; | |
| 31 | + { what git describe says, made by make: 0.3.0 at the tag v0.3.0, | |
| 32 | + 0.3.0-5-g38d29a8 five commits past it } | |
| 33 | + Version = {$I version.inc}; | |
| 32 | 34 | Report = '2026-10.0'; { the version of doc/raz.md it follows } |
| 33 | 35 | MemfdCreate = 319; { the system call; FPC 3.2.2 has no name for it } |
| 34 | 36 | MfdCloexec = 1; { an ELF still executes: the kernel opens it first } |