Merge pull request #20 from noahstreller/chore/automatic-release-note… #61
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint, build and upload Igitt | |
on: | |
push: | |
# branches: ["main"] | |
tags: | |
- "*" | |
pull_request: | |
branches: ["main"] | |
jobs: | |
lint: | |
# run on self-hosted runner to reduce usage quota | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23" | |
- name: Lint | |
run: | | |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
golangci-lint run | |
test: | |
needs: lint | |
# run on github hosted runner to avoid waste of resources | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23" | |
- name: Test | |
run: go test -v ./... | |
buildStatusCheck: | |
if: github.event_name == 'pull_request' | |
runs-on: self-hosted | |
needs: [lint, test] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23" | |
- name: Build | |
run: | | |
go build -o /dev/null ./cmd/igitt; | |
build: | |
env: | |
LATEST_TAG: ${{ github.ref_name }} | |
needs: [lint, test] | |
if: startsWith(github.ref, 'refs/tags/') | |
# run on self-hosted runner to reduce usage quota | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
goos: [linux, windows, darwin] | |
goarch: [amd64, arm64] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23" | |
- name: Set GOOS and GOARCH | |
run: | | |
echo "GOOS=${{ matrix.goos }}" >> $GITHUB_ENV | |
echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
if [[ "${{ matrix.goos }}" == "windows" ]]; then \ | |
go build -v -o out/igitt.exe ./cmd/igitt; \ | |
else \ | |
go build -v -o out/igitt ./cmd/igitt; \ | |
fi | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: igitt-${{ matrix.goos }}-${{ matrix.goarch }}-${{ env.LATEST_TAG }} | |
path: | | |
out/igitt* | |
build-windows-setup: | |
needs: build | |
runs-on: windows-latest | |
env: | |
LATEST_TAG: ${{ github.ref_name }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: igitt-windows-amd64-* | |
- name: Copy Build Artifacts | |
run: | | |
cp igitt-windows-amd64-*/* . | |
- name: Compile .ISS to .EXE Installer | |
uses: Minionguyjpro/[email protected] | |
with: | |
path: ./igitt-setup.iss | |
options: /Oout | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: igitt-setup-windows-amd64-${{ env.LATEST_TAG }} | |
path: | | |
out/igitt* | |
pre-release: | |
permissions: | |
contents: write | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: build-windows-setup | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: igitt-* | |
- name: Create ZIP Archives | |
run: | | |
for dir in igitt-*; do | |
zip -r "${dir}.zip" "$dir" | |
done | |
- name: debug-tree | |
run: | | |
tree | |
- name: Release on GitHub | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
igitt-* | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: "Automatic Pre-Release: ${{ github.ref_name }}" | |
body: | | |
This is an automatic pre-release build. See the generated release notes below | |
generate_release_notes: true | |
# if tag contains debug, it should be a draft release | |
draft: ${{ contains(github.ref, 'debug') }} | |
prerelease: true |