From 39442c75a74f06524e1ed1b54281ea2f43286ccd Mon Sep 17 00:00:00 2001 From: Robb Date: Thu, 22 Jun 2023 17:12:34 -0500 Subject: [PATCH 1/5] Try to implement reusable action --- .github/workflows/build-base.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/build.yml | 13 +------------ 2 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/build-base.yml diff --git a/.github/workflows/build-base.yml b/.github/workflows/build-base.yml new file mode 100644 index 0000000..3e4888e --- /dev/null +++ b/.github/workflows/build-base.yml @@ -0,0 +1,29 @@ +name: "build" + +on: + workflow_call: + +jobs: + build: + name: "Build" + runs-on: "ubuntu-latest" + + env: + GOOS: windows + GOARCH: amd64 + + permissions: write-all + + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.19 + + - name: Verify dependencies + run: go mod verify + + - name: Build + run: go build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cad2604..cd82816 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,18 +17,7 @@ jobs: permissions: write-all steps: - - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.19 - - - name: Verify dependencies - run: go mod verify - - - name: Build - run: go build + - uses: ./.github/workflows/build-base.yml - name: Upload artifacts uses: actions/upload-artifact@v3 From 34c75e262095749e4dfe350dbc80b9cfcbff94e7 Mon Sep 17 00:00:00 2001 From: Robb Date: Thu, 22 Jun 2023 17:14:45 -0500 Subject: [PATCH 2/5] Hopefully fix action call syntax --- .github/workflows/build.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd82816..56ae223 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,18 +7,15 @@ on: jobs: build: + uses: ./.github/workflows/build-base.yml + + upload: name: "Build" runs-on: "ubuntu-latest" - env: - GOOS: windows - GOARCH: amd64 - permissions: write-all steps: - - uses: ./.github/workflows/build-base.yml - - name: Upload artifacts uses: actions/upload-artifact@v3 with: From 3d48fe83fb5c7c1ed8a16e4aa187272e8d887a8b Mon Sep 17 00:00:00 2001 From: Robb Date: Thu, 22 Jun 2023 17:15:55 -0500 Subject: [PATCH 3/5] Require build job to complete first --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56ae223..7584558 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,11 @@ jobs: uses: ./.github/workflows/build-base.yml upload: - name: "Build" + name: "Upload artifacts" runs-on: "ubuntu-latest" + needs: build + permissions: write-all steps: From 3304ca0a41e7d8c0a8cc1c6e806c5500375ba7bf Mon Sep 17 00:00:00 2001 From: Robb Date: Thu, 22 Jun 2023 17:29:37 -0500 Subject: [PATCH 4/5] Upload artifacts to allow passing between jobs --- .github/workflows/build-base.yml | 10 +++++++-- .github/workflows/build.yml | 16 -------------- .github/workflows/release.yml | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-base.yml b/.github/workflows/build-base.yml index 3e4888e..0eebbea 100644 --- a/.github/workflows/build-base.yml +++ b/.github/workflows/build-base.yml @@ -12,8 +12,6 @@ jobs: GOOS: windows GOARCH: amd64 - permissions: write-all - steps: - uses: actions/checkout@v2 @@ -27,3 +25,11 @@ jobs: - name: Build run: go build + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: version + path: | + SMEI.exe + README.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7584558..b6dd984 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,19 +8,3 @@ on: jobs: build: uses: ./.github/workflows/build-base.yml - - upload: - name: "Upload artifacts" - runs-on: "ubuntu-latest" - - needs: build - - permissions: write-all - - steps: - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: executable - path: | - SMEI.exe diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a294bf8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: "release" + +on: + push: + branches: + # - 'main' + - 'auto-prerelease' # TODO change this to main once working + +jobs: + build: + uses: ./.github/workflows/build-base.yml + + release: + name: "Release" + runs-on: "ubuntu-latest" + + needs: build + + permissions: write-all + + steps: + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: version + + - uses: "marvinpinto/action-automatic-releases@latest" + name: Create prerelease + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "latest" + prerelease: true + title: "Automatic Pre-Release" + files: | + README.md + SMEI.exe From 6e8b9d2ffbad4abdbf434adeba27908a91ac3926 Mon Sep 17 00:00:00 2001 From: Robb Date: Thu, 22 Jun 2023 17:39:41 -0500 Subject: [PATCH 5/5] Switch auto prerelease creator to only work on main branch now that it's working --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a294bf8..7a58f48 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,8 +3,7 @@ name: "release" on: push: branches: - # - 'main' - - 'auto-prerelease' # TODO change this to main once working + - 'main' jobs: build: