|
1 | 1 | name: Github Release
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - workflow_run: |
5 |
| - workflows: |
6 |
| - - Lint Test Build |
7 |
| - branches: |
8 |
| - - main |
9 |
| - types: |
10 |
| - - completed |
| 4 | + workflow_run: |
| 5 | + workflows: |
| 6 | + - Lint Test Build |
| 7 | + branches: |
| 8 | + - master |
| 9 | + types: |
| 10 | + - completed |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_NAME: ${{ github.repository }} |
11 | 15 |
|
12 | 16 | jobs:
|
13 |
| - release: |
14 |
| - name: Release to GitHub |
| 17 | + build-and-push-image: |
15 | 18 | runs-on: ubuntu-latest
|
16 |
| - |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
17 | 22 | steps:
|
18 |
| - - name: Checkout code |
19 |
| - uses: actions/checkout@v3 |
20 |
| - |
21 |
| - - name: Set up Go |
22 |
| - uses: actions/setup-go@v4 |
23 |
| - with: |
24 |
| - go-version: 1.19 |
25 |
| - |
26 |
| - - name: Cache Go modules |
27 |
| - uses: actions/cache@v3 |
28 |
| - with: |
29 |
| - path: ~/go/pkg/mod |
30 |
| - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
31 |
| - restore-keys: | |
32 |
| - ${{ runner.os }}-go- |
33 |
| -
|
34 |
| - - name: Install dependencies |
35 |
| - run: go mod download |
36 |
| - |
37 |
| - - name: Build binary |
38 |
| - run: | |
39 |
| - mkdir -p dist |
40 |
| - GOOS=linux GOARCH=amd64 go build -o dist/GoCrab-linux-amd64 . |
41 |
| - GOOS=darwin GOARCH=amd64 go build -o dist/GoCrab-darwin-amd64 . |
42 |
| - GOOS=windows GOARCH=amd64 go build -o dist/GoCrab-windows-amd64.exe . |
43 |
| -
|
44 |
| - - name: Create Release |
45 |
| - id: create_release |
46 |
| - uses: actions/create-release@v1 |
47 |
| - with: |
48 |
| - tag_name: ${{ github.ref_name }} |
49 |
| - release_name: "GoCrab ${{ github.ref_name }}" |
50 |
| - body: | |
51 |
| - Automated release for GoCrab version ${{ github.ref_name }}. |
52 |
| - Includes pre-built binaries for Linux, macOS, and Windows. |
53 |
| - draft: false |
54 |
| - prerelease: false |
55 |
| - env: |
56 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
57 |
| - |
58 |
| - - name: Upload Release Assets |
59 |
| - uses: actions/upload-release-asset@v1 |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + - name: Log in to the Container registry |
| 26 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
60 | 27 | with:
|
61 |
| - upload_url: ${{ steps.create_release.outputs.upload_url }} |
62 |
| - asset_path: dist/GoCrab-linux-amd64 |
63 |
| - asset_name: GoCrab-linux-amd64 |
64 |
| - asset_content_type: application/octet-stream |
65 |
| - |
66 |
| - - name: Upload macOS Binary |
67 |
| - uses: actions/upload-release-asset@v1 |
| 28 | + registry: ${{ env.REGISTRY }} |
| 29 | + username: ${{ github.actor }} |
| 30 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + - name: Extract metadata (tags, labels) for Docker |
| 32 | + id: meta |
| 33 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
68 | 34 | with:
|
69 |
| - upload_url: ${{ steps.create_release.outputs.upload_url }} |
70 |
| - asset_path: dist/GoCrab-darwin-amd64 |
71 |
| - asset_name: GoCrab-darwin-amd64 |
72 |
| - asset_content_type: application/octet-stream |
73 |
| - |
74 |
| - - name: Upload Windows Binary |
75 |
| - uses: actions/upload-release-asset@v1 |
| 35 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 36 | + - name: Build and push fractal Docker image |
| 37 | + id: gocrab |
| 38 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
76 | 39 | with:
|
77 |
| - upload_url: ${{ steps.create_release.outputs.upload_url }} |
78 |
| - asset_path: dist/GoCrab-windows-amd64.exe |
79 |
| - asset_name: GoCrab-windows-amd64.exe |
80 |
| - asset_content_type: application/octet-stream |
| 40 | + context: . |
| 41 | + push: true |
| 42 | + tags: ${{ steps.meta.outputs.tags }} |
| 43 | + labels: ${{ steps.meta.outputs.labels }} |
| 44 | + file: ./Dockerfile |
| 45 | + |
0 commit comments