Skip to content

Commit

Permalink
Generate META.json
Browse files Browse the repository at this point in the history
Rather than modify it in the repository and potentially create weird
conflicts. Generate it from an input file, instead. Use the new
`GIT_BUNDLE_OPTS` variable for the pgxn/pgxn-tools container to add the
generated `META.json` file to the bundle. It would otherwise be excluded
because `git archive` includes only committed files.
  • Loading branch information
theory committed Jan 22, 2024
1 parent 26dbf33 commit 4e96906
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.gitignore export-ignore
.gitattributes export-ignore
.github export-ignore
*.bak export-ignore
META.json export-ignore
3 changes: 2 additions & 1 deletion .github/workflows/pgxn-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4
- name: Bundle the Release
run: make META.json.bak && pgxn-bundle
env: { GIT_BUNDLE_OPTS: --add-file META.json }
run: make META.json && pgxn-bundle
- name: Release on PGXN
env:
PGXN_USERNAME: ${{ secrets.PGXN_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
**/*.rs.bk
.env
.trunk
*.bak
META.json
File renamed without changes.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DISTNAME = $(shell grep -m 1 '^name' Trunk.toml | sed -e 's/[^"]*"\([^"]*\)",\{0,1\}/\1/')
DISTVERSION = $(shell grep -m 1 '^version' Cargo.toml | sed -e 's/[^"]*"\([^"]*\)",\{0,1\}/\1/')

format:
Expand All @@ -8,9 +9,13 @@ format:
run:
PGLATER_SOCKET_URL='postgresql:///pg_later?host=/Users/${USER}/.pgrx&user=${USER}&dbname=pg_later&port=28815' cargo pgrx run

META.json.bak: Cargo.toml META.json
@sed -i.bak "s/@CARGO_VERSION@/$(DISTVERSION)/g" META.json
META.json: META.json.in Trunk.toml
@sed "s/@CARGO_VERSION@/$(DISTVERSION)/g" $< > $@

pgxn-zip: META.json.bak
git archive --format zip --prefix=pg_later-$(DISTVERSION)/ -o pg_later-$(DISTVERSION).zip HEAD
@mv META.json.bak META.json
$(DISTNAME)-$(DISTVERSION).zip: META.json
git archive --format zip --prefix $(DISTNAME)-$(DISTVERSION)/ --add-file $< -o $(DISTNAME)-$(DISTVERSION).zip HEAD

pgxn-zip: $(DISTNAME)-$(DISTVERSION).zip

clean:
@rm -rf META.json $(DISTNAME)-$(DISTVERSION).zip

0 comments on commit 4e96906

Please sign in to comment.