diff --git a/.github/workflows/gorelaser.yml b/.github/workflows/gorelaser.yml index 3bdda74f..c8e38692 100644 --- a/.github/workflows/gorelaser.yml +++ b/.github/workflows/gorelaser.yml @@ -1,9 +1,12 @@ -name: goreleaser +name: Build and release on: - label: - types: created - + # label: + # types: created + push: + tags: + - 'v*' + workflow_dispatch: permissions: contents: write @@ -12,25 +15,35 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - cache-dependency-path: "go.sum" + + - name: Set tag reference from input + if: github.event.ref != '' + run: | + echo "GIT_REF=refs/tags/${{ github.event.ref}}" >> $GITHUB_ENV + + - name: Set tag reference from github.ref + if: github.ref != '' + run: | + echo "GIT_REF=${{ github.ref }}" >> $GITHUB_ENV - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 - with: - # either 'goreleaser' (default) or 'goreleaser-pro' - distribution: goreleaser - # 'latest', 'nightly', or a semver - version: '~> v2' - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution - # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ env.GIT_REF }} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + cache-dependency-path: "go.sum" + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index d1e891d9..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Release Pipeline - -on: - push: - tags: ["**"] - -permissions: - contents: write - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - os: [linux, windows, darwin, freebsd] - arch: [amd64, arm64, arm] - exclude: - - os: darwin - arch: arm - - os: windows - arch: arm - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - - name: Get the current commit - id: get_commit - run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - - name: Get the current date - id: get_date - run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT - - - name: Build binary - run: | - VERSION=${{ github.ref_name }} - COMMIT=${{ steps.get_commit.outputs.commit }} - DATE=${{ steps.get_date.outputs.date }} - GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} CGO_ENABLED=0 go build -o immich-go-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }} -ldflags="-s -w -extldflags=-static -X version.Version=$VERSION -X version.Commit=$COMMIT -X version.Date=$DATE" main.go - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.os }}-${{ matrix.arch}} - path: "./immich-go-*" - if-no-files-found: error - - release: - needs: build - runs-on: ubuntu-latest - steps: - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - path: "./artifacts" - - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - files: "./artifacts/**" - draft: false - prerelease: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index c6c5915d..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Test Pipeline - -on: - workflow_dispatch: - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - - name: Test - run: go test -v ./... diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 212551cb..d2a68870 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -18,17 +18,17 @@ builds: - windows - darwin - freebsd - goarch: + goarch: - amd64 - arm - arm64 flags: - -trimpath ldflags: - - '-s -w "-extldflags=-static" -X version.Version={{.Version}} -X version.Commit={{.Commit}} -X Version.Date={{.Date}} -X main.builtBy=goreleaser' + - -extldflags=-static -X github.com/simulot/immich-go/app.Version={{.Version}} -X github.com/simulot/immich-go/Commit={{.Commit}} -X github.com/simulot/immich-go/Date={{.Date}} -s -w archives: - - format: tar.gz + - formats: ['tar.gz'] # this name template makes the OS and Arch compatible with the results of uname. name_template: >- {{ .ProjectName }}_ @@ -39,208 +39,28 @@ archives: {{- if .Arm }}v{{ .Arm }}{{ end }} # use zip for windows archives format_overrides: - - goos: windows - format: zip + - goos : windows + formats: ['zip'] + files: + - LICENSE checksum: name_template: 'checksums.txt' snapshot: - name_template: "{{ incpatch .Version }}-next" + version_template: "{{ incpatch .Version }}-next" changelog: sort: asc filters: exclude: - '^docs:' - '^test:' - -# The lines beneath this are called `modelines`. See `:help modeline` -# Feel free to remove those if you don't want/use them. -# yaml-language-server: $schema=https://goreleaser.com/static/schema.json -# vim: set ts=2 sw=2 tw=0 fo=cnqoj - -# .goreleaser.yaml + - '^chore:' + release: - # Repo in which the release will be created. - # Default: extracted from the origin remote URL or empty if its private hosted. - # github: - # owner: user - # name: repo - - # IDs of the archives to use. - # Empty means all IDs. - # - # Default: []. - # ids: - # - foo - # - bar - - # If set to true, will not auto-publish the release. - # Note: all GitHub releases start as drafts while artifacts are uploaded. - # Available only for GitHub and Gitea. draft: true - - # Whether to remove existing draft releases with the same name before creating - # a new one. - # - # Only effective if `draft` is set to true. - # Available only for GitHub. replace_existing_draft: true - - # Whether to remove an artifact that already exists. - # - # Available only for GitHub. - # This might be a bit expensive (rate-limiting speaking), so it is only done - # when the upload of an artifact fails with a 422 (which means it already - # exists in the release). - # We then grab the list of artifacts from the release, and delete the file - # that matches the one we're trying to upload. - # GoReleaser will then retry its upload. replace_existing_artifacts: true - - # Useful if you want to delay the creation of the tag in the remote. - # You can create the tag locally, but not push it, and run GoReleaser. - # It'll then set the `target_commitish` portion of the GitHub release to the - # value of this field. - # Only works on GitHub. - # - # Default: ''. - # Templates: allowed. - target_commitish: "{{ .Commit }}" - - # This allows to change which tag GitHub will create. - # Usually you'll use this together with `target_commitish`, or if you want to - # publish a binary from a monorepo into a public repository somewhere, without - # the tag prefix. - # - # This feature is only available in GoReleaser Pro. - # Default: '{{ .PrefixedCurrentTag }}'. - # Templates: allowed. - # tag: "{{ .CurrentTag }}" - - # If set, will create a release discussion in the category specified. - # - # Warning: do not use categories in the 'Announcement' format. - # Check https://github.com/goreleaser/goreleaser/issues/2304 for more info. - # - # Default: ''. - # discussion_category_name: General - - # If set to auto, will mark the release as not ready for production - # in case there is an indicator for this in the tag e.g. v1.0.0-rc1 - # If set to true, will mark the release as not ready for production. - # Default: false. + use_existing_draft: true prerelease: auto - - # If set to false, will NOT mark the release as "latest". - # This prevents it from being shown at the top of the release list, - # and from being returned when calling https://api.github.com/repos/OWNER/REPO/releases/latest. - # - # Available only for GitHub. - # - # Default: true. make_latest: true - - # What to do with the release notes in case there the release already exists. - # - # Valid options are: - # - `keep-existing`: keep the existing notes - # - `append`: append the current release notes to the existing notes - # - `prepend`: prepend the current release notes to the existing notes - # - `replace`: replace existing notes - # - # Default: `keep-existing`. mode: append - # Header for the release body. - # - # Templates: allowed. - # header: | - # ## Some title ({{ .Date }}) - - # Welcome to this new release! - - # Header for the release body. - # - # This feature is only available in GoReleaser Pro. - # header: - # # Loads from an URL. - # from_url: - # # Templates: allowed. - # url: https://foo.bar/header.md - # headers: - # x-api-token: "${MYCOMPANY_TOKEN}" - - # # Loads from a local file. - # # Overrides `from_url`. - # from_file: - # # Templates: allowed. - # path: ./header.md - - # Footer for the release body. - # - # Templates: allowed. - # footer: | - # ## Thanks - - # Those were the changes on {{ .Tag }}! - - # Footer for the release body. - # - # This feature is only available in GoReleaser Pro. - # footer: - # # Loads from an URL. - # from_url: - # # Templates: allowed. - # url: https://foo.bar/footer.md - # footers: - # x-api-token: "${MYCOMPANY_TOKEN}" - - # # Loads from a local file. - # # Overrides `from_url`. - # from_file: - # # Templates: allowed. - # path: ./footer.md - - # # You can change the name of the release. - # # - # # Default: '{{.Tag}}' ('{{.PrefixedTag}}' on Pro). - # # Templates: allowed. - # name_template: "{{.ProjectName}}-v{{.Version}} {{.Env.USER}}" - - # You can disable this pipe in order to not create the release on any SCM. - # Keep in mind that this might also break things that depend on the release - # URL, for instance, homebrew taps. - # - # Templates: allowed. - disable: true - - # Set this to true if you want to disable just the artifact upload to the SCM. - # If this is true, GoReleaser will still create the release with the - # changelog, but won't upload anything to it. - # - # Templates: allowed. - skip_upload: true - - # You can add extra pre-existing files to the release. - # The filename on the release will be the last part of the path (base). - # If another file with the same name exists, the last one found will be used. - # - # Templates: allowed. - # extra_files: - # - glob: ./path/to/file.txt - # - glob: ./glob/**/to/**/file/**/* - # - glob: ./glob/foo/to/bar/file/foobar/override_from_previous - # - glob: ./single_file.txt - # name_template: file.txt # note that this only works if glob matches 1 file only - - # Additional templated extra files to add to the release. - # Those files will have their contents pass through the template engine, - # and its results will be added to the release. - # - # This feature is only available in GoReleaser Pro. - # Templates: allowed. - # templated_extra_files: - # - src: LICENSE.tpl - # dst: LICENSE.txt - - # # Upload metadata.json and artifacts.json to the release as well. - # include_meta: true \ No newline at end of file