diff --git a/.github/actions/build-unclog/action.yml b/.github/actions/build-unclog/action.yml new file mode 100644 index 0000000..f392959 --- /dev/null +++ b/.github/actions/build-unclog/action.yml @@ -0,0 +1,52 @@ +name: build-unclog +description: builds the unclog binary from source + +inputs: + artifact-name: + required: false + type: string +outputs: + artifact-name: + description: "name of uploaded artifact" + value: ${{ steps.artifact-namer.outputs.artifact-name }} + +runs: + using: "composite" + steps: + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Build + shell: bash + run: go build -o unclog -v . + + - name: Default binary name + if: ${{ inputs.artifact-name != '' }} + shell: bash + run: | + echo "UNCLOG_BINARY_NAME={{ $inputs.artifact-name }}" >> ${GITHUB_ENV} + + - name: Scoped name in PR + if: ${{ inputs.artifact-name == '' && github.event_name == 'pull_request' }} + shell: bash + run: | + echo "UNCLOG_BINARY_NAME=unclog-${{ github.event.pull_request.head.sha }}" >> ${GITHUB_ENV} + - name: Scoped name on push + if: ${{ inputs.artifact-name == '' && github.event_name == 'push' }} + shell: bash + run: | + echo "UNCLOG_BINARY_NAME=unclog-${GITHUB_SHA}" >> ${GITHUB_ENV} + + - name: Set artifact-name output parameter + id: artifact-namer + shell: bash + run: | + echo "artifact-name=${UNCLOG_BINARY_NAME}" >> "$GITHUB_OUTPUT" + + - name: Upload unclog binary + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact-namer.outputs.artifact-name }} + path: unclog diff --git a/.github/workflows/changelog-check.yml b/.github/workflows/dogfood.yml similarity index 51% rename from .github/workflows/changelog-check.yml rename to .github/workflows/dogfood.yml index 4ce87b0..b2ff8ea 100644 --- a/.github/workflows/changelog-check.yml +++ b/.github/workflows/dogfood.yml @@ -1,44 +1,28 @@ # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go -name: changelog-check +name: dogfood on: pull_request: branches: [ "main" ] jobs: - build-changelog-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - - - name: Build - run: go build -o unclog -v . - - - name: Upload linter binary - uses: actions/upload-artifact@v3 - with: - name: changelog-check-binary - path: unclog - run-changelog-check: runs-on: ubuntu-latest - needs: build-changelog-check - steps: - name: Checkout source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: build-unclog + id: unclog-build + uses: ./.github/actions/build-unclog - name: Download changelog check binary - uses: actions/download-artifact@v3 + id: unclog-download + uses: actions/download-artifact@v4 with: - name: changelog-check-binary + name: ${{ steps.unclog-build.outputs.artifact-name }} - name: Get new changelog files id: new-changelog-files @@ -48,6 +32,10 @@ jobs: log/**.md - name: Run lint command + shell: bash env: ALL_ADDED_MARKDOWN: ${{ steps.new-changelog-files.outputs.added_files }} - run: chmod +x unclog && ./unclog check -fragment-env=ALL_ADDED_MARKDOWN + #UNCLOG_BIN: ${{ steps.unclog-download.outputs.download-path}}/${{ steps.unclog-build.outputs.artifact-name }} + #UNCLOG_DIR: ${{ steps.unclog-download.outputs.download-path}} + run: | + chmod +x unclog && ./unclog check -fragment-env=ALL_ADDED_MARKDOWN diff --git a/.github/workflows/main-artifact-refresh.yml b/.github/workflows/main-artifact-refresh.yml new file mode 100644 index 0000000..09fda0e --- /dev/null +++ b/.github/workflows/main-artifact-refresh.yml @@ -0,0 +1,21 @@ +name: main-artifact-refresh +description: "ensures there is always an unclog artifact available, building monthly (less than 90 day retention period) or when PRs merge to main" + +on: + pull_request: + types: + - closed + schedule: + - cron: "0 0 1 * *" # run first day of month + +jobs: + refresh-unclog-binary: + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: build-unclog + uses: ./.github/actions/build-unclog + with: + artifact-name: unclog # This is the 'release' artifact name diff --git a/log/kasey_test-build-action.md b/log/kasey_test-build-action.md new file mode 100644 index 0000000..4e97d33 --- /dev/null +++ b/log/kasey_test-build-action.md @@ -0,0 +1,3 @@ +### Changed + +- refactored github actions to be composable between local workflow testing and artifact "release"