ast tests, workflows, readme #23
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 and Release | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: release | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
include: | |
- goos: windows | |
goarch: amd64 | |
- goos: darwin | |
goarch: amd64 | |
- goos: darwin | |
goarch: arm64 | |
- goos: linux | |
goarch: amd64 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.23 | |
- name: Build | |
run: | | |
BINARY_NAME="irule-validator-${{ matrix.goos }}-${{ matrix.goarch }}" | |
if [ "${{ matrix.goos }}" = "windows" ]; then | |
BINARY_NAME="${BINARY_NAME}.exe" | |
fi | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${BINARY_NAME} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binary-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: irule-validator-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
- name: Get latest tag | |
id: get_tag | |
run: | | |
git fetch --tags | |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "v0.0.0") | |
new_tag=$(echo $latest_tag | awk -F. -v OFS=. '{$NF = $NF + 1;} 1') | |
echo "new_tag=$new_tag" >> $GITHUB_ENV | |
echo "previous_tag=$latest_tag" >> $GITHUB_ENV | |
- name: Delete previous release | |
run: | | |
latest_release=$(gh release list -L 1 | cut -f1 || echo "v0.0.0") | |
if [ "$latest_release" != "v0.0.0" ]; then | |
gh release delete $latest_release -y || true | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file_glob: true | |
file: binary-*/* | |
tag: ${{ env.new_tag }} | |
overwrite: true | |
make_latest: true | |
prerelease: false | |
body: "Release ${{ env.new_tag }}" |