Skip to content

Commit b5f32b4

Browse files
committed
fix: add ga workflow to publish releases
1 parent fcc21c0 commit b5f32b4

File tree

5 files changed

+76
-5
lines changed

5 files changed

+76
-5
lines changed

.github/workflows/release.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: 'stable'
20+
21+
- name: Run Semantic Release
22+
id: release
23+
uses: cycjimmy/semantic-release-action@v4
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Get release version
28+
if: steps.release.outputs.new_release_published == 'true'
29+
run: echo "RELEASE_VERSION=$(echo ${{ steps.release.outputs.new_release_version }})" >> $GITHUB_ENV
30+
31+
- name: Build with version
32+
env:
33+
VERSION: ${{ env.RELEASE_VERSION }}
34+
run: bash ./scripts/build.sh
35+
36+
- name: Upload release assets
37+
if: steps.release.outputs.new_release_published == 'true'
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: binaries
41+
path: dist/
42+
43+
- name: Create GitHub Release
44+
if: steps.release.outputs.new_release_published == 'true'
45+
uses: softprops/action-gh-release@v2
46+
with:
47+
files: dist/*
48+
tag_name: "v${{ env.RELEASE_VERSION }}"
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.releaserc.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"branches": [
3+
"master"
4+
],
5+
"plugins": [
6+
"@semantic-release/commit-analyzer"
7+
]
8+
}

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# j2z
22

3-
The goal of this project is to provide a simple tool to convert a Jekyll markdown posts to Zola markdown posts.
3+
Simple CLI tool to convert a Jekyll markdown posts to Zola markdown posts.
44

55
## Usage:
66

@@ -13,4 +13,7 @@ j2z --jekyllDir <path> --zolaDir <path> [--tz <timezone>] [--taxonomies <taxonom
1313
- `--zolaDir` (required): Specifies the path to the Zola directory containing the `content` directory.
1414
- `--tz` (optional): Sets the timezone for the conversion. If not provided, the timezone will default to the local machine's timezone. Example: `America/New_York`.
1515
- `--taxonomies` (optional): A comma-separated list of taxonomies to include in the conversion. Default is `tags,categories`.
16-
- `--aliases` (optional): Enables aliases in the front matter if set to `true`. Default is `true`.
16+
- `--aliases` (optional): Enables aliases in the front matter if set to `true`. Default is `false`.
17+
18+
## TODO:
19+
- [ ] Add relative link conversion

scripts/build.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
CGO_ENABLED=0
44
DIST_DIR="dist"
5+
VERSION=${VERSION:-dev}
56

67
platforms=("linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64" "windows/amd64" "windows/arm64")
78

@@ -15,6 +16,7 @@ do
1516
output="$output.exe"
1617
fi
1718

18-
echo "Building $output"
19-
CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GOARCH=$GOARCH go build -gcflags="all=-l -B" -trimpath -ldflags="-s -w" -o $output ./src
19+
echo "Building $output with version $VERSION"
20+
CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GOARCH=$GOARCH \
21+
go build -gcflags="all=-l -B" -trimpath -ldflags="-s -w -X main.Version=$VERSION" -o "$output" ./src
2022
done

src/main.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@ func splitFlag(flagValue string) []string {
2626
return strings.Split(flagValue, ",")
2727
}
2828

29+
var Version = "dev"
30+
2931
func main() {
3032
jekyllDirFlag := flag.String("jekyllDir", "", "Path to the Jekyll directory")
3133
zolaDirFlag := flag.String("zolaDir", "", "Path to the Zola directory")
3234
taxonomiesFlag := flag.String("taxonomies", "tags,categories", "Optional comma-separated list of taxonomies")
3335
tzNameFlag := flag.String("tz", "", "Optional timezone name")
34-
alisesFlag := flag.Bool("aliases", true, "Optional flag to enable aliases in the front matter")
36+
alisesFlag := flag.Bool("aliases", false, "Optional flag to enable aliases in the front matter")
37+
versionFlag := flag.Bool("version", false, "Print the version number")
3538
flag.Parse()
3639

40+
if *versionFlag {
41+
logger.Printf("version %s\n", Version)
42+
os.Exit(0)
43+
}
44+
3745
cliArgs := Args{
3846
jekyllDir: *jekyllDirFlag,
3947
zolaDir: *zolaDirFlag,

0 commit comments

Comments
 (0)