diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 1a4b126..0b63d88 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -11,7 +11,6 @@ jobs: test: name: Test runs-on: ubuntu-latest - if: github.server_url == 'https://github.com' steps: - uses: actions/checkout@v4 @@ -35,7 +34,6 @@ jobs: lint: name: Lint runs-on: ubuntu-latest - if: github.server_url == 'https://github.com' steps: - uses: actions/checkout@v4 @@ -55,11 +53,38 @@ jobs: exit 1 fi + release: + name: Create Release + runs-on: ubuntu-latest + needs: [test, lint] + if: startsWith(github.ref, 'refs/tags/v') + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build: name: Build and Push Docker Image runs-on: ubuntu-latest needs: [test, lint] - if: github.event_name == 'push' && github.server_url == 'https://github.com' + if: github.event_name == 'push' permissions: contents: read packages: write diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..bde0d96 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,48 @@ +version: 2 + +before: + hooks: + - go mod tidy + +builds: + - id: apocapoc-api + main: ./cmd/api + binary: apocapoc-api + env: + - CGO_ENABLED=1 + goos: + - linux + goarch: + - amd64 + - arm64 + ldflags: + - -s -w + +archives: + - id: apocapoc-api + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + format: tar.gz + files: + - README.md + - LICENSE + +checksum: + name_template: 'checksums.txt' + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - '^ci:' + - Merge pull request + - Merge branch + +release: + github: + owner: davidfolch + name: apocapoc-api + draft: false + prerelease: auto + name_template: "{{.Tag}}" diff --git a/README.md b/README.md index 6915f58..3c30240 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,21 @@ The API will be available at `http://localhost:8080` ### Using the binary -1. Download the latest release -2. Copy `.env.example` to `.env` and configure -3. Run: `./apocapoc-api` +1. Download the latest release from [GitHub Releases](https://github.com/davidfolch/apocapoc-api/releases) +2. Extract the archive: + ```bash + tar -xzf apocapoc-api_*_linux_amd64.tar.gz + ``` +3. Copy `.env.example` to `.env` and configure +4. Run the binary: + ```bash + ./apocapoc-api + ``` The API will be available at `http://localhost:8080` +**Note:** Linux binaries only (amd64 and arm64). For other platforms, use Docker. + ## Development ### Prerequisites