๐Ÿš€ GitHub Action์€ ๊ฐ€๋Šฅํ•œ ํ•œ ๋น ๋ฅด๊ณ  ์‰ฝ๊ฒŒ Go ํ”„๋กœ์ ํŠธ๋ฅผ ๊ฒŒ์‹œํ•ฉ๋‹ˆ๋‹ค.

19766 ๋‹จ์–ด gogithubtutorialbeginners

์†Œ๊ฐœ


์•ˆ๋…•ํ•˜์„ธ์š”, DEV World!๐Ÿ˜‰ ์ด ์‹œ๋ฆฌ์ฆˆ๋ฅผ ๊ณ„์†ํ•˜์—ฌ ์šฐ์ˆ˜ํ•œ CI/CD ๋„๊ตฌ์ธ GitHub ์ž‘์—… ์ž๋™ํ™” ๋ฃจํ‹ด์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค.
์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰ ์ค‘์— ์ž๋™์œผ๋กœ ๋ฐœํ‘œ๋  ๋•Œ๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

๐Ÿ“ ์นดํƒˆ๋กœ๊ทธ


  • What will we automate?
  • Repository structure
  • Configure GitHub Action
  • Troubleshooting

  • Time to release!
  • Real-life example
  • Questions for better understanding
  • Exercises for independent execution
  • ๐Ÿค” ์šฐ๋ฆฌ๋Š” ๋ฌด์—‡์„ ์ž๋™ํ™”ํ•  ๊ฒƒ์ž…๋‹ˆ๊นŒ?


    ๋งŒ์•ฝ ๋‹น์‹ ์ด ์„œ๋กœ ๋‹ค๋ฅธ ํ”Œ๋žซํผ/์šด์˜์ฒด์ œ๋ฅผ ์œ„ํ•ด Go์— ์ ํžŒ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ฐœํ‘œํ•˜๋Š” ๋„์ „์— ์ง๋ฉดํ•œ ์ ์ด ์žˆ๋‹ค๋ฉด, ๋‹น์‹ ์€ ์–ด๋–ค ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ฒŒ ๋ ์ง€ ์ด๋ฏธ ์•Œ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.๋งŒ์•ฝ ์—†๋‹ค๋ฉด, ๋‚˜๋Š” ์•ฝ๊ฐ„์˜ ๊ฒƒ์„ ๊ฐ€์ง€๊ณ  ์˜ฌ ๊ฒƒ์ด๋‹ค.
  • ๊ฐ ์šด์˜ ์ฒด์ œ์˜ ๊ธฐ๋Šฅ์„ ๊ณ„์† ๋ชจ๋‹ˆํ„ฐ๋งํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค(์˜ˆ: ๊ฒฝ๋กœ์˜ ํŠน์ • ์Šฌ๋ž˜์‹œ).
  • ์•„์นด์ด๋ธŒ๋ฅผ ์ˆ˜๋™์œผ๋กœ ์ž‘์„ฑํ•˜์—ฌ GitHub์˜ ๊ฒŒ์‹œ ํŽ˜์ด์ง€์— ์—…๋กœ๋“œํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • ๋ชจ๋“  ์ œ์ถœ์„ ํ™•์ธํ•˜์—ฌ CHANGELOG์„ ์ƒˆ ๋ฒ„์ „์œผ๋กœ ๋งŒ๋“ค์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • ...๋” ์žˆ์–ด!
  • ๊ทธ๋ ‡๋‹ค๋ฉด, ๋งŒ์•ฝ ๋‚ด๊ฐ€ ๋‹น์‹ ์—๊ฒŒ ๋ฉ”๋ชจ๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ํ‘œ์‹œ๋ฅผ ๋งŒ๋“  ํ›„์— ์ž๋™์œผ๋กœ ์ด ๋ชจ๋“  ๊ฒƒ์„ ์™„์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ๊ฐ€ ์žˆ๋‹ค๊ณ  ์•Œ๋ ค์ค€๋‹ค๋ฉด?
    ๋†๋‹ด์ด ์•„๋‹ˆ์—์š”. GoReleaser GitHub ์กฐ์ž‘์œผ๋กœ ์ด ๋ชจ๋“  ๊ฒƒ์„ ์™„์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.๐Ÿ‘‡

    goreleaser ํšŒ์‚ฌ / goreleaser ๋™์ž‘


    : octocat: GoReleaser์˜ GitHub ์ž‘์—…



    GoReleaser ๋™์ž‘


    GoReleaser GitHub Action






  • Usage
  • Workflow
  • Run on new tag
  • Signing
  • Upload artifacts
  • Install Only

  • Customizing
  • inputs
  • environment variables
  • Limitation
  • Development
  • License
  • ํ™œ์šฉ๋‹จ์–ด์ฐธ์กฐ


    ์›Œํฌํ”Œ๋กœ์šฐ

    name: goreleaser
    
    on:
      pull_request:
      push:
    
    jobs:
      goreleaser:
        runs-on: ubuntu-latest
        steps:
          -
            name: Checkout
            uses: actions/checkout@v2
            with:
              fetch-depth: 0
          -
            name: Set up Go
            uses: actions/setup-go@v2
            with:
              go-version: 1.15
          -
            name: Run GoReleaser
            uses: goreleaser/goreleaser-action@v2
            with:
              # either 'goreleaser' (default) or 'goreleaser-pro'
              distribution: goreleaser
              version: latest
              args: release --rm-dist
            env:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
              # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
              # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

    IMPORTANT: note the fetch-depth: 0 input in Checkout step. It is required for the changelog to work correctly.

    ์ƒˆ ํƒญ์—์„œ ์‹คํ–‰

    If you want to run GoReleaser onlyโ€ฆ

    โ†‘ Table of contents

    ๐Ÿ‘€ ์ €์žฅ์†Œ ๊ตฌ์กฐ

    For a short, project will be contain very simple function:

    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hi, DEV World! ๐Ÿ˜‰")
    }
    
    ์ด๋ ‡๊ฒŒ ๊ฐ„๋‹จํ•œ ์ €์žฅ์†Œ ๊ตฌ์กฐ:
    .
    โ”œโ”€โ”€ .github
    โ”‚   โ””โ”€โ”€ workflows
    โ”‚       โ””โ”€โ”€ release_build.yml  # <-- GitHub Action
    โ””โ”€โ”€ main.go                    # <-- main function
    
    โ†‘ Table of contents

    ๐Ÿค– GitHub ์ž‘์—… ๊ตฌ์„ฑ


    ์šฐ๋ฆฌ ๊ณ„์† ์ด์•ผ๊ธฐํ•  ์ฃผ์ธ๊ณต.ํŒŒ์ผ release_build.yml์˜ ๋ชฉ๋ก์„ ๋ณด์‹ญ์‹œ์˜ค. ์ด๋ฏธ ์ต์ˆ™ํ•œ ์š”์†Œ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค. (GitHub ์ž‘์—…์— ๊ด€ํ•œ ๋‚˜์˜ ๊ธ€์„ ์ฝ์—ˆ๋‹ค๋ฉด)๐Ÿ˜):
    name: Release Go project
    
    on:
      push:
        tags:
          - "*" # triggers only if push new tag version, like `0.8.4` or else
    
    jobs:
      build:
        name: GoReleaser build
        runs-on: ubuntu-latest
    
        steps:
          - name: Check out code into the Go module directory
            uses: actions/checkout@v2
            with:
              fetch-depth: 0 # See: https://goreleaser.com/ci/actions/
    
          - name: Set up Go 1.14
            uses: actions/setup-go@v2
            with:
              go-version: 1.14
            id: go
    
          - name: Run GoReleaser
            uses: goreleaser/goreleaser-action@master
            with:
              version: latest
              args: release --rm-dist
            env:
              GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
    
    ์˜ˆ. GitHub๋Š” ์›Œํฌํ”Œ๋กœ์šฐ์—์„œ ์‚ฌ์šฉํ•  GITHUB_TOKEN ์•”ํ˜ธ๋ฅผ ์ž๋™์œผ๋กœ ๋งŒ๋“ค์ง€๋งŒ repo ์—ญํ•  ์˜์—ญ here์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž์‹ ์˜ ํ† ํฐ์„ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

    ์ด์ œ ์ƒˆ GitHub secret์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค(์˜ˆ: GO_RELEASER_GITHUB_TOKEN).

    โ†‘ Table of contents

    โœ… ๋ฌธ์ œ ํ•ด๊ฒฐ

    main() ํ•จ์ˆ˜๋ฅผ ๊ฐ€์ง„ ํŒŒ์ผ์ด ์ €์žฅ์†Œ์˜ ๋ฃจํŠธ ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์—†์œผ๋ฉด GoReleaser์—์„œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.๋”ฐ๋ผ์„œ ๋‹จ๊ณ„ ์„ค์ •์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ฌ๋ฐ”๋ฅธ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์ง€์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    # ...
    
        steps:
    
          # ...
    
          - name: Run GoReleaser
            uses: goreleaser/goreleaser-action@master
            with:
              version: latest
              args: release --rm-dist
              workdir: ./cmd/myapp # <-- path to directory with main() func
            env:
              GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
    
    โ†‘ Table of contents

    ๐Ÿš€ ๋ฐœํ‘œํ•ด์•ผ ๋ผ!


    ๋ ˆ์ด๋ธ”์ด ์žˆ๋Š” ์ƒˆ ๋ฒ„์ „์„ ๋งŒ๋“ค๊ณ  (์˜ˆ: 0.8.4) ์ž‘์—… ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

    ์ž‘์—…์„ ์„ฑ๊ณต์ ์œผ๋กœ ๋งˆ์นœ ํ›„ ๋ฐœํ‘œ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜์—ฌ ๊ฒฝ์™ธ์Šค๋Ÿฌ์šด ๊ฒฐ๊ณผ๋ฅผ ๋ณด์‹ญ์‹œ์˜ค. CHANGELOG, ๋ชจ๋“  ์ œ์ถœ(๋‘ ๋ฒ„์ „ ์‚ฌ์ด), checksums.txt ํŒŒ์ผ๊ณผ ์—…๋กœ๋“œ๋œ ํŒŒ์ผ, ๊ทธ๋ฆฌ๊ณ  ๋ชจ๋“  ํ”Œ๋žซํผ์˜ ์ปดํŒŒ์ผ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค!

    ๊ทธ๋ ‡์Šต๋‹ˆ๋‹ค!์ด๋ ‡๊ฒŒ!๐ŸŽ‰
    โ†‘ Table of contents

    ๐ŸŽฏ ์‹ค์ œ ์ƒํ™œ์˜ ์˜ˆ


    ๋งŒ์•ฝ ์œ„์˜ ์บก์ฒ˜๊ฐ€ ๋ถ€์กฑํ•˜๋‹ค๋ฉด, ๋‚˜๋Š” ๋„ˆ์—๊ฒŒ ๋‚˜์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ณด์—ฌ ๋‹ฌ๋ผ๊ณ  ์ดˆ๋Œ€ํ•œ๋‹ค. ๊ฑฐ๊ธฐ์—์„œ ๋‚˜๋Š” ํ˜„์‹ค ์ƒํ™œ์—์„œ GoReleaser ๋™์ž‘์„ ์‚ฌ์šฉํ•œ๋‹ค.

    go ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๋งŒ๋“ค๊ธฐ / cli


    โœจ CLI ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์—ฌ ๋ฐฑ์—”๋“œ, ํ”„๋ŸฐํŠธ์—”๋“œ ๋ฐ ๋ฐฐํฌ ์ž๋™ํ™”๋ฅผ ๊ฐ–์ถ˜ ์ƒˆ๋กœ์šด ํ”„๋กœ๋•์…˜ ์ค€๋น„ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค!


    Go App CLI ์ƒ์„ฑ


    CLI ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์—ฌ ๋ฐฑ์—”๋“œ(Golang), ํ”„๋ŸฐํŠธ์—”๋“œ(JavaScript, TypeScript) ๋ฐ ๋ฐฐํฌ ์ž๋™ํ™”(Ansible, Docker)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒˆ ํ”„๋กœ๋•์…˜ ์ค€๋น„ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.์ฝ”๋“œ ์ž‘์„ฑ๊ณผ ์—…๋ฌด ๋…ผ๋ฆฌ์— ์ „๋…ํ•˜์„ธ์š”!CLI๊ฐ€ ๋‚˜๋จธ์ง€ ๋ถ€๋ถ„์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
    ย  ย  ย 

    โšก๏ธ ๋น ๋ฅธ ์‹œ์ž‘


    ๋จผ์ € download์„ ์„ค์น˜ํ•˜๊ณ  Go๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.1.17 ์ด์ƒ์˜ ๋ฒ„์ „์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

    If you're looking for the Create Go App CLI for Go 1.16, you can find it here.


    go install ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜๋ฅผ ์™„๋ฃŒํ•˜๊ณ  $GOPATH/bin์— ์„ค์น˜๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ ํŒŒ์ผ์˜ ์ด๋ฆ„์„ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.
    github๋ฅผ ์„ค์น˜ํ•˜๋Ÿฌ ๊ฐ€์„ธ์š”.com/create-go-app/cli/v3/cmd/cgapp@latest
    ๋˜ํ•œ macOS ๋ฐ GNU/Linux ์‚ฌ์šฉ์ž๋Š” Homebrew์„ ํ†ตํ•ด ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    # ์ƒˆ ๊ณต์‹์„ ํด๋ฆญ:
    brew ํด๋ฆญcreate go app/cli
    # ์„ค์น˜:
    brew ์„ค์น˜create go app/cli/cgapp
    ๋Œ€ํ™”ํ˜• ์ฝ˜์†” UI(CUI)๋ฅผ ํ†ตํ•ด ํ˜„์žฌ ํด๋”์— ์ƒˆ ํ•ญ๋ชฉ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
    cgapp ๋งŒ๋“ค๊ธฐ
    ๋‹ค์Œ์— ์ƒ์„ฑ๋œ Ansible ๋ชฉ๋ก ํŒŒ์ผ(hosts.ini)์„ ์—ด๊ณ ...
    View on GitHub
    โ†‘ Table of contents

    ๐Ÿ’ฌ ๋” ์ž˜ ์ดํ•ด๋˜๋Š” ๋ฌธ์ œ

  • GitHub ์ž‘์—… ๊ตฌ์„ฑ์—์„œ ์ž‘์—…์„ ํŠธ๋ฆฌ๊ฑฐํ•˜๋Š” ๋งค๊ฐœ ๋ณ€์ˆ˜๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?
  • ์™œ ์šฐ๋ฆฌ๋Š” fetch-depth: 0 ์กฐ์ž‘์— actions/checkout์„ ์ •์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๊นŒ?
  • -rm-dist ๋งค๊ฐœ ๋ณ€์ˆ˜๋Š” Run GoReleaser ๋‹จ๊ณ„์—์„œ ๋ฌด์—‡์„ ์˜๋ฏธํ•ฉ๋‹ˆ๊นŒ?
  • โ†‘ Table of contents

    โœ๏ธ ๊ฐœ๋ณ„ ์‹คํ–‰ ์—ฐ์Šต

  • ์€ ๊ธ€์—์„œ ๋ณด์‹  ๋ชจ๋“  ๋‚ด์šฉ์„ ๋ฐ˜๋ณตํ•˜์ง€๋งŒ Golang ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.์•„๋ž˜์˜ ๋Œ“๊ธ€์— ๋‹น์‹ ์˜ ๊ฒฐ๊ณผ๋ฅผ ์จ์„œ ๋‹น์‹ ์˜ ๋น„๊ต์  ์งง์€ ์‚ฌ์ดํŠธ์— ๋งํฌํ•ด ์ฃผ์‹ญ์‹œ์˜ค!
  • ์€ ํŠธ๋ฆฌ๊ฑฐ ๊ฐ’์„ ์ฃผ์š” ๋ฒ„์ „์—๋งŒ ์ ์šฉํ•˜๋„๋ก ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.์†Œํ”„ํŠธ์›จ์–ด ๋ฒ„์ „ ์ œ์–ด here์— ๋Œ€ํ•œ ๋” ๋งŽ์€ ์ •๋ณด๋ฅผ ๋ณด์‹ญ์‹œ์˜ค.
  • โ†‘ Table of contents

    ์‚ฌ์ง„ / ์ด๋ฏธ์ง€ ์ž‘์„ฑ์ž

  • GoReleaser Action repository & website (Link: 1, 2)
  • GitHub ์ €์žฅ์†Œ ์„ค์ •(link)
  • ๋ถ“์„ ๋Œ€๋‹ค.


    ๋” ๋งŽ์€ ๊ฒƒ์„ ์•Œ๊ณ  ์‹ถ์œผ๋ฉด ์•„๋ž˜์— ํ‰๋ก ์„ ํ•˜๋‚˜ ์“ฐ์‹œ๊ณ  ๋”ฐ๋ผ์˜ค์„ธ์š”.๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.๐Ÿ˜˜

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ