forked from golang-migrate/migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for GitHub Actions and goreleaser (golang-migrate#604)
* goreleaser configuration and automatic release workflow * update and fix goreleaser * remove windows arm ignore * add format override for windows to use zip files * update environment and docker username * the single source of truth * fix depricated api issue ( thanks @dhui ) Co-authored-by: Mitsuo Heijo <[email protected]>
- Loading branch information
1 parent
5bf05dc
commit 5a601b9
Showing
5 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
jobs: | ||
goreleaser: | ||
name: Release a new version | ||
environment: GoReleaser | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16.x" | ||
|
||
- uses: docker/setup-qemu-action@v1 | ||
- uses: docker/setup-buildx-action@v1 | ||
- uses: docker/login-action@v1 | ||
with: | ||
username: golangmigrate | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- run: echo "SOURCE=$(make echo-source)" >> $GITHUB_ENV | ||
- run: echo "DATABASE=$(make echo-database)" >> $GITHUB_ENV | ||
|
||
- uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- run: gem install package_cloud | ||
- run: package_cloud push golang-migrate/migrate/ubuntu/bionic dist/migrate.linux-amd64.deb | ||
env: | ||
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} | ||
- run: package_cloud push golang-migrate/migrate/ubuntu/focal dist/migrate.linux-amd64.deb | ||
env: | ||
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} | ||
- run: package_cloud push golang-migrate/migrate/debian/buster dist/migrate.linux-amd64.deb | ||
env: | ||
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ cli/migrate | |
.godoc.pid | ||
vendor/ | ||
.vscode/ | ||
.idea/ | ||
.idea | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
project_name: migrate | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm | ||
- arm64 | ||
- 386 | ||
goarm: | ||
- 7 | ||
main: ./cmd/migrate | ||
ldflags: | ||
- '-w -s -X main.Version={{ .Version }} -extldflags "static"' | ||
flags: | ||
- "-tags={{ .Env.DATABASE }} {{ .Env.SOURCE }}" | ||
- "-trimpath" | ||
nfpms: | ||
- homepage: "https://github.com/golang-migrate/migrate" | ||
maintainer: "[email protected]" | ||
license: MIT | ||
description: "Database migrations" | ||
formats: | ||
- deb | ||
file_name_template: "{{ .ProjectName }}.{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" | ||
dockers: | ||
- goos: linux | ||
goarch: amd64 | ||
dockerfile: Dockerfile.github-actions | ||
use: buildx | ||
ids: | ||
- migrate | ||
image_templates: | ||
- 'migrate/migrate:{{ .Tag }}-amd64' | ||
build_flag_templates: | ||
- '--label=org.opencontainers.image.created={{ .Date }}' | ||
- '--label=org.opencontainers.image.title={{ .ProjectName }}' | ||
- '--label=org.opencontainers.image.revision={{ .FullCommit }}' | ||
- '--label=org.opencontainers.image.version={{ .Version }}' | ||
- "--label=org.opencontainers.image.source={{ .GitURL }}" | ||
- "--platform=linux/amd64" | ||
- goos: linux | ||
goarch: arm64 | ||
dockerfile: Dockerfile.github-actions | ||
use: buildx | ||
ids: | ||
- migrate | ||
image_templates: | ||
- 'migrate/migrate:{{ .Tag }}-arm64' | ||
build_flag_templates: | ||
- '--label=org.opencontainers.image.created={{ .Date }}' | ||
- '--label=org.opencontainers.image.title={{ .ProjectName }}' | ||
- '--label=org.opencontainers.image.revision={{ .FullCommit }}' | ||
- '--label=org.opencontainers.image.version={{ .Version }}' | ||
- "--label=org.opencontainers.image.source={{ .GitURL }}" | ||
- "--platform=linux/arm64" | ||
|
||
docker_manifests: | ||
- name_template: 'migrate/migrate:{{ .Tag }}' | ||
image_templates: | ||
- 'migrate/migrate:{{ .Tag }}-amd64' | ||
- 'migrate/migrate:{{ .Tag }}-arm64' | ||
- name_template: 'migrate/migrate:{{ .Major }}' | ||
image_templates: | ||
- 'migrate/migrate:{{ .Tag }}-amd64' | ||
- 'migrate/migrate:{{ .Tag }}-arm64' | ||
- name_template: 'migrate/migrate:latest' | ||
image_templates: | ||
- 'migrate/migrate:{{ .Tag }}-amd64' | ||
- 'migrate/migrate:{{ .Tag }}-arm64' | ||
archives: | ||
- name_template: "{{ .ProjectName }}.{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
checksum: | ||
name_template: 'sha256sum.txt' | ||
release: | ||
draft: true | ||
changelog: | ||
skip: false | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
- Merge pull request | ||
- Merge branch | ||
- go mod tidy | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM alpine:3.13 | ||
|
||
RUN apk add --no-cache ca-certificates | ||
|
||
ENTRYPOINT ["/usr/bin/migrate"] | ||
CMD ["--help"] | ||
|
||
COPY migrate /usr/bin/migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters