diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 0000000..e654a3b --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,98 @@ +--- +name: "CI/CD" + +"on": + push: + pull_request: + +jobs: + pre-commit-job: + runs-on: "ubuntu-22.04" + steps: + - name: "Check out repository" + uses: "actions/checkout@v4.1.6" + - name: "Setup python" + uses: "actions/setup-python@v5.1.0" + - name: "Run pre-commit" + uses: "pre-commit/action@v3.0.1" + + go-test-job: + runs-on: "ubuntu-22.04" + steps: + - name: "Check out repository" + uses: "actions/checkout@v4.1.6" + - name: "Setup go" + uses: "actions/setup-go@v5.0.1" + with: + go-version: "1.22.3" + - name: "Run go test" + run: "go test ./..." + + go-build-job: + runs-on: "ubuntu-22.04" + steps: + - name: "Check out repository" + uses: "actions/checkout@v4.1.6" + - name: "Setup go" + uses: "actions/setup-go@v5.0.1" + with: + go-version: "1.22.3" + - name: "Run go build" + run: "go build" + + mirror-gitlab-job: + runs-on: "ubuntu-22.04" + steps: + - name: "Check out repository" + uses: "actions/checkout@v4.1.6" + with: + fetch-depth: 0 + - name: "Add Gitlab Remote" + run: | + git remote add gitlab https://oauth2:${{ secrets.GITLAB_LABDOC_MIRROR_TOKEN }}@gitlab.com/erNail/labdoc.git + - name: "Push all branches to GitLab" + run: "git push gitlab --all --force" + + - name: "Push all tags to GitLab" + run: "git push gitlab --tags --force" + + release-job: + runs-on: "ubuntu-22.04" + needs: + - "go-test-job" + - "go-build-job" + - "pre-commit-job" + - "mirror-gitlab-job" + permissions: + contents: "write" + steps: + - name: "Check out repository" + uses: "actions/checkout@v4.1.6" + with: + fetch-depth: 0 + - name: "Setup go" + uses: "actions/setup-go@v5.0.1" + with: + go-version: "1.22.3" + - name: "Setup node" + uses: "actions/setup-node@v4.0.2" + with: + node-version: "22.2.0" + - name: "Setup goreleaser" + run: "go install github.com/goreleaser/goreleaser/v2@v2.0.0" + - name: "Login to Docker Hub" + uses: "docker/login-action@v3.2.0" + with: + username: "${{ secrets.DOCKER_USERNAME }}" + password: "${{ secrets.DOCKER_LABDOC_GORELEASER_TOKEN }}" + - name: "Run semantic-release" + uses: "cycjimmy/semantic-release-action@v4.1.0" + with: + extra_plugins: | + @semantic-release/changelog@6.0.3 + @semantic-release/exec@6.0.3 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + DOCKER_LABDOC_GORELEASER_TOKEN: "${{ secrets.DOCKER_LABDOC_GORELEASER_TOKEN }}" + HOMEBREW_TAP_ERNAIL_GITHUB_TOKEN: "${{ secrets.HOMEBREW_TAP_ERNAIL_GITHUB_TOKEN }}" +... diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..d5c3ded --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,45 @@ +--- +version: 2 + +before: + hooks: + - "go mod tidy" + +builds: + + - env: + - "CGO_ENABLED=0" + goos: + - "darwin" + - "linux" + goarch: + - "amd64" + - "arm64" + +# Container Image build +kos: + - repository: "ernail/labdoc" + base_image: "alpine:3.20.0" + tags: + - "{{ .Version }}" + bare: true + preserve_import_paths: false + platforms: + - "linux/amd64" + - "linux/arm64" + +brews: + - name: "labdoc" + caveats: "Run `labdoc -h` to get started!" + homepage: "https://github.com/erNail/labdoc" + description: "Automatically generate documentation for GitLab CI/CD components and CI/CD pipelines." + license: "MIT" + commit_msg_template: "chore: Update brew formula for {{ .ProjectName }} version {{ .Tag }}" + repository: + owner: "erNail" + name: "homebrew-tap" + branch: "feature/formula-update" + token: "{{ .Env.HOMEBREW_TAP_ERNAIL_GITHUB_TOKEN }}" + pull_request: + enabled: true +... diff --git a/taskfile.yaml b/taskfile.yaml new file mode 100644 index 0000000..e0a8bf8 --- /dev/null +++ b/taskfile.yaml @@ -0,0 +1,36 @@ +--- +version: "3" + +tasks: + lint: + cmds: + - "pre-commit run --all-files" + + test: + cmds: + - "go test ./..." + + run: + cmds: + - "go run main.go {{ .CLI_ARGS }}" + + run-generate: + cmds: + - "go run main.go generate --repoUrl gitlab.com/erNail/labdoc {{ .CLI_ARGS }}" + + build: + cmds: + - "go build" + + build-image: + cmds: + - "ko build --platform all --local" + + release-test: + cmds: + - "semantic-release --dry-run" + + test-github-actions: + cmds: + - "act" +...