Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ultra.mega.har
test-5k.har
harific-demo.gif
harific-logo.png
.git/
go.work
go.work.sum
39 changes: 39 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.25
id: go

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 50
fetch-tags: true
show-progress: true

- name: Check go mod tidy is up to date
run: go mod tidy && git diff --exit-code

- name: Get dependencies
run: go get -v -t -d ./...

- name: Test
run: go test ./...

- name: Build
run: make build
118 changes: 118 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Publish

on:
repository_dispatch:
types: [publish-event]

jobs:
release_and_brew:
name: Release and bump homebrew version
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
id: go
with:
go-version: 1.25

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish_npm:
name: Publish to NPM
needs: release_and_brew
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 50
fetch-tags: true
show-progress: true

- name: Check version
run: echo "Version ${{ github.event.client_payload.new-tag }}"

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Setup Git user
run: |
git config --global user.name "Github Bot"
git config --global user.email "[email protected]"

- name: Create .npmrc file
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Bump NPM version
run: npm --no-git-tag-version --allow-same-version version ${{ github.event.client_payload.new-tag }}

- name: NPM publish
run: npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

push_to_registries:
name: Push Docker image to multiple registries
needs: release_and_brew
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 50
fetch-tags: true
show-progress: true

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
pb33f/harific
ghcr.io/pb33f/harific

- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: pb33f/harific:latest, pb33f/harific:${{ github.event.client_payload.new-tag }}, ghcr.io/pb33f/harific:latest, ghcr.io/pb33f/harific:${{ github.event.client_payload.new-tag }}
labels: ${{ steps.meta.outputs.labels }}
58 changes: 58 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Tag Release

on:
push:
branches:
- main

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions-ecosystem/action-get-merged-pull-request@v1
id: get-merged-pull-request
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions-ecosystem/action-release-label@v1
id: release-label
if: ${{ steps.get-merged-pull-request.outputs.title != null }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: ${{ steps.get-merged-pull-request.outputs.labels }}

- uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
if: ${{ steps.release-label.outputs.level != null }}
with:
semver_only: true

- uses: actions-ecosystem/action-bump-semver@v1
id: bump-semver
if: ${{ steps.release-label.outputs.level != null }}
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: ${{ steps.release-label.outputs.level }}

- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
text: ${{ steps.get-merged-pull-request.outputs.body }}
regex: '```release_note([\s\S]*)```'

- uses: actions-ecosystem/action-push-tag@v1
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
tag: ${{ steps.bump-semver.outputs.new_version }}
message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ steps.get-merged-pull-request.outputs.number }} ${{ steps.get-merged-pull-request.outputs.title }}"

- uses: peter-evans/repository-dispatch@v1
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: pb33f/harific
event-type: publish-event
client-payload: '{"new-tag": "${{ steps.bump-semver.outputs.new_version }}", "release-notes": "${{ steps.regex-match.outputs.group1 }}"}'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testdata/
*.har
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ builds:
- linux
- windows
- darwin
main: ./cmd/harific
main: ./harific.go
archives:
- name_template: >-
{{ .ProjectName }}_
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY . ./
RUN go mod download && go mod verify
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags="-w -s -X 'main.version=$(git describe --tags --abbrev=0 2>/dev/null || echo dev)' -X 'main.date=$(date +%Y-%m-%dT%TZ)'" \
-v -o harific ./cmd/harific
-v -o harific harific.go

FROM debian:bookworm-slim

Expand Down
Loading