1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00

release workflow, first cut

This commit is contained in:
Rene Schallner 2023-05-22 02:02:04 +02:00
parent 27ab749281
commit 66e1a31efb
4 changed files with 143 additions and 1 deletions

66
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,66 @@
name: Create Release, update README, send announceybot
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install discord-webhook GitPython
- name: Set tag name
id: tag
run: |
echo "::set-output name=version::${GITHUB_REF#refs/tags/}"
- name: Generate release notes
id: release_notes
run: |
echo "::set-output name=notes::$(python tools/announceybot/generate_releasenotes.py "${{ steps.tag.outputs.version }}")"
- name: Run script to update README
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.tag.outputs.version }}
run: |
python tools/announceybot/update_readme.py "${TAG_NAME}"
- name: Commit and push if it has changed
run: |
git diff
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Update README"
git push
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ steps.tag.outputs.version }} # Remove 'refs/tags/' from the tag name
body: ${{ steps.release_notes.outputs.notes }} # Use the release notes from the output of the previous step
- name: Announce Release
env:
TAG_NAME: ${{ steps.tag.outputs.version }}
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
python tools/announceybot/announceybot.py "${TAG_NAME}"

View file

@ -36,7 +36,9 @@ def get_replacement():
if __name__ == '__main__':
annotation = get_tag_annotation(TAG_NAME)
zon_update = get_replacement()
message = f'''# New release {TAG_NAME}!
message = f'''# TEST-RUN TEST-RUN TEST-RUN
# New release {TAG_NAME}!
## Updates

View file

@ -0,0 +1,27 @@
import sys
import os
from git import Repo
import subprocess
TAG_NAME = os.getenv("TAG_NAME", sys.argv[1])
def get_tag_annotation(tagname):
repo = Repo('.')
tag = repo.tags[tagname]
return tag.tag.message
def get_replacement():
ret = subprocess.run([
"./zig-out/bin/pkghash",
"-g", f"--tag={TAG_NAME}",
"--template=./tools/announceybot/release-note-template.md",
], capture_output=True)
text = ret.stdout.decode("utf-8")
return text
if __name__ == '__main__':
annotation = get_tag_annotation(TAG_NAME)
print(get_replacement().replace("{{UPDATES}}", annotation))

View file

@ -0,0 +1,47 @@
# ZAP Release {tag}
## Updates
{{UPDATES}}
## Using it
To use in your own projects, put this dependency into your `build.zig.zon`:
```zig
// zap {tag}
.zap = .{
.url = "https://github.com/zigzap/zap/archive/refs/tags/{tag}.tar.gz",
.hash = "{hash}",
}
```
Here is a complete `build.zig.zon` example:
```zig
.{
.name = "My example project",
.version = "0.0.1",
.dependencies = .{
// zap {tag}
.zap = .{
.url = "https://github.com/zigzap/zap/archive/refs/tags/{tag}.tar.gz",
.hash = "{hash}",
}
}
}
```
Then, in your `build.zig`'s `build` function, add the following before
`exe.install()`:
```zig
const zap = b.dependency("zap", .{
.target = target,
.optimize = optimize,
});
exe.addModule("zap", zap.module("zap"));
exe.linkLibrary(zap.artifact("facil.io"));
```