gha: if not on main
, create a prerelease
#70
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: Build | |
on: | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- '**' | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
minio: | |
image: bitnami/minio:latest | |
ports: | |
- "9000:9000" | |
env: | |
MINIO_ROOT_USER: minio | |
MINIO_ROOT_PASSWORD: password | |
steps: | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: "1.18" | |
- uses: actions/checkout@v4 | |
- name: Download Modules | |
run: go mod download | |
- name: Generate | |
run: go generate ./... | |
- name: Build | |
env: | |
GOOS: linux | |
GOARCH: amd64 | |
CGO_ENABLED: "0" | |
run: go build -ldflags="-X cas/version.GitCommit=${{ github.sha }} -X cas/version.Prerelease=""" | |
- name: Test | |
env: | |
CAS_S3_TEST_ENDPOINT: "http://localhost:9000" | |
run: go test -v ./... | |
- name: Store Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cas | |
path: cas | |
- name: Generate Release Notes - Main | |
if: ${{ github.ref_name == 'main' }} | |
run: | | |
echo "CAS_VERSION=$(./cas version --short)" >> "${GITHUB_ENV}" | |
./cas version --changelog --raw | tee release-notes.md | |
- name: Generate Release Notes - Branch | |
if: ${{ github.ref_name != 'main' }} | |
run: | | |
echo "CAS_VERSION=$(git rev-parse --short HEAD)" >> "${GITHUB_ENV}" | |
./cas version --changelog --raw | tee release-notes.md | |
- name: Check if Changelog has changed | |
uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
changelog: | |
- 'changelog.md' | |
- name: PreRelease | |
if: ${{ github.ref_name != 'main' }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ env.CAS_VERSION }} | |
tag_name: ${{ env.CAS_VERSION }} | |
body_path: release-notes.md | |
prerelease: true | |
files: cas | |
- name: Release | |
if: ${{ github.ref_name == 'main' && steps.changes.outputs.changelog == 'true' }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ env.CAS_VERSION }} | |
tag_name: ${{ env.CAS_VERSION }} | |
body_path: release-notes.md | |
files: cas |