1+ name : Build release from tag
2+ on :
3+ push :
4+ tags :
5+ - ' v*.*.*'
6+
7+ env :
8+ ko_version : 0.12.0
9+
10+ jobs :
11+ publish_github :
12+ name : Build latest and publish to ghcr
13+ runs-on : ubuntu-latest
14+ permissions :
15+ packages : write
16+ steps :
17+ - name : Get version from tags
18+ id : version
19+ run : echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
20+
21+ - name : Set up Go 1.x
22+ uses : actions/setup-go@v3
23+ with :
24+ go-version : ^1.19
25+
26+ - name : Check out code into the Go module directory
27+ uses : actions/checkout@v3
28+
29+ - name : Build
30+ run : go build -v .
31+
32+ - name : Test
33+ run : go test -v ./...
34+
35+ - name : Install KO
36+ run : |
37+ curl -L https://github.com/google/ko/releases/download/v${{ env.ko_version }}/ko_${{ env.ko_version }}_Linux_x86_64.tar.gz | tar xzf - ko
38+ chmod +x ./ko
39+ - name : Publish docker image
40+ env :
41+ KO_DOCKER_REPO : ghcr.io/${{ github.repository_owner }}
42+ run : |
43+ ./ko login ghcr.io --username $GITHUB_REPOSITORY_OWNER --password ${{ secrets.GITHUB_TOKEN }}
44+ ./ko publish -B --tags v${{ steps.version.outputs.tag }} .
45+ publish_google :
46+ name : Build latest and publish to pkg.dev
47+ runs-on : ubuntu-latest
48+ permissions :
49+ id-token : write
50+ contents : read
51+ steps :
52+ - name : Get version from tags
53+ id : version
54+ run : echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
55+
56+ - name : Set up Go 1.x
57+ uses : actions/setup-go@v3
58+ with :
59+ go-version : ^1.19
60+
61+ - name : Check out code into the Go module directory
62+ uses : actions/checkout@v3
63+
64+ - name : Build
65+ run : go build -v .
66+
67+ - name : Test
68+ run : go test -v ./...
69+
70+ - name : Install KO
71+ run : |
72+ curl -L https://github.com/google/ko/releases/download/v${{ env.ko_version }}/ko_${{ env.ko_version }}_Linux_x86_64.tar.gz | tar xzf - ko
73+ chmod +x ./ko
74+ - name : Authenticate with Google Cloud
75+ id : auth
76+ uses : google-github-actions/auth@v1
77+ with :
78+ token_format : access_token
79+ workload_identity_provider : ${{ secrets.GCP_IDENTITY_PROVIDER }}
80+ service_account : ${{ secrets.GCP_SERVICE_ACCOUNT }}
81+ access_token_lifetime : 300s
82+
83+ - name : Publish docker image
84+ env :
85+ KO_DOCKER_REPO : europe-north1-docker.pkg.dev/cloud-418/mope
86+ run : |
87+ ./ko login europe-north1-docker.pkg.dev --username oauth2accesstoken --password ${{ steps.auth.outputs.access_token }}
88+ ./ko publish -B --tags v${{ steps.version.outputs.tag }} .
0 commit comments