diff --git a/.changie.yaml b/.changie.yaml new file mode 100644 index 0000000..a4dc700 --- /dev/null +++ b/.changie.yaml @@ -0,0 +1,23 @@ +changesDir: changes +unreleasedDir: unreleased +headerPath: header.tpl.md +changelogPath: CHANGELOG.md +versionExt: md +versionFormat: '## [{{ .Version }}](https://github.com/skyoo2003/devcloud/releases/tag/{{ .Version }}) - {{ .Time.Format "2006-01-02" }}' + + +kindFormat: "### {{ .Kind }}" +changeFormat: "* {{ .Body }} ([#{{ .Custom.Issue }}](https://github.com/skyoo2003/devcloud/issues/{{ .Custom.Issue }}))" +kinds: + - label: Added + - label: Changed + - label: Deprecated + - label: Removed + - label: Fixed + - label: Security + - label: Documentation +custom: + - key: Issue + label: Issue Number + type: int + minInt: 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..acd8e4f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + attestations: write + steps: + - name: Checkout the code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@41dfa10bef8ca8f7c4c7cec63b269ccb8a9156b9 # v6 + with: + go-version-file: go.mod + cache-dependency-path: go.sum + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Verify changie release notes exist + run: | + if [ ! -f "changes/${{ github.ref_name }}.md" ]; then + echo "::error::Changie fragment changes/${{ github.ref_name }}.md not found." + echo "::error::Run 'changie batch ${{ github.ref_name }}' and 'changie merge' before pushing the tag." + exit 1 + fi + - name: Execute GoReleaser + uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # goreleaser-action v7 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean --release-notes changes/${{ github.ref_name }}.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload assets + uses: actions/upload-artifact@5d5df5e032fcb57d3c9d9901e9b8f8b2b7d8051a # v7 + with: + name: devcloud + path: dist/* diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..7ea5be1 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,67 @@ +version: 2 + +project_name: devcloud + +env: +- GO111MODULE=on +- CGO_ENABLED=0 + +before: + hooks: + - go mod download + +builds: +- id: devcloud + binary: devcloud + main: cmd/devcloud/main.go + goos: + - darwin + - linux + - windows + goarch: + - amd64 + - arm64 + +archives: +- id: devcloud + format: tar.gz + format_overrides: + - goos: windows + format: zip + files: + - LICENSE + - README.md + - CHANGELOG.md + +changelog: + disable: false + +checksum: + algorithm: sha256 + name_template: 'CHECKSUMS' + +dockers_v2: +- images: + - ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/{{ .ProjectName }} + dockerfile: Dockerfile.goreleaser + ids: + - devcloud + sbom: false + flags: + - "--provenance=false" + tags: + - "{{ .Tag }}-alpine" + - "v{{ .Major }}.{{ .Minor }}-alpine" + - "v{{ .Major }}-alpine" + - "latest-alpine" + labels: + org.opencontainers.image.created: "{{ .Date }}" + org.opencontainers.image.source: "https://github.com/{{ .Env.GITHUB_REPOSITORY_OWNER }}/{{ .ProjectName }}" + org.opencontainers.image.title: "{{ .ProjectName }}" + org.opencontainers.image.revision: "{{ .FullCommit }}" + org.opencontainers.image.version: "{{ .Version }}" + +release: + name_template: "{{ .Version }}" + disable: false + mode: replace diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser new file mode 100644 index 0000000..675689c --- /dev/null +++ b/Dockerfile.goreleaser @@ -0,0 +1,11 @@ +FROM --platform=$BUILDPLATFORM alpine:3.21 + +RUN adduser --system --home /devcloud appuser +VOLUME /devcloud +WORKDIR /devcloud +ARG TARGETOS +ARG TARGETARCH +COPY ${TARGETOS}/${TARGETARCH}/devcloud /usr/bin/devcloud + +USER appuser +ENTRYPOINT ["devcloud"] diff --git a/Makefile b/Makefile index 15a4669..72adeec 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build test codegen run clean test-compat build-web build-all docker-build docker-run +.PHONY: build test codegen run clean test-compat build-web build-all docker-build docker-run changelog build: go build -o dist/devcloud ./cmd/devcloud @@ -32,3 +32,10 @@ docker-run: clean: rm -rf dist/ data/ + +changelog: + @if [ -z "$(VERSION)" ]; then \ + echo "VERSION is required. Usage: make changelog VERSION=v0.2.0"; \ + exit 1; \ + fi + @changie batch $(VERSION) && changie merge diff --git a/changes/header.tpl.md b/changes/header.tpl.md new file mode 100644 index 0000000..e69de29