add support for old compose file #7
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: Build and Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.19' | |
- name: Determine Version | |
id: determine_version | |
run: | | |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF##*/} | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV # Extract the tag name | |
else | |
echo "Unrecognized reference, exiting." | |
exit 1 # Exit if it's neither a tag nor main branch | |
fi | |
echo "TAG_URL=https://github.com/${{ github.repository }}/releases/tag/${{ env.VERSION }}" >> $GITHUB_ENV | |
- name: Get Previous Tag | |
id: get_previous_tag | |
run: | | |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
# Get all tags, sort them semantically, and find the previous one | |
PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -E '^v' | awk -v current_tag="${VERSION}" '{ | |
if ($0 == current_tag) { | |
found = 1; next | |
} | |
if (found) { | |
print $0; exit | |
} | |
}') | |
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV | |
fi | |
- name: Build for Linux | |
run: | | |
GOOS=linux GOARCH=amd64 go build -o dockermi-linux-${{ env.VERSION }} main.go | |
tar -czvf dockermi-linux-${{ env.VERSION }}.tar.gz dockermi-linux-${{ env.VERSION }} | |
- name: Build for macOS | |
run: | | |
GOOS=darwin GOARCH=amd64 go build -o dockermi-macos-${{ env.VERSION }} main.go | |
tar -czvf dockermi-macos-${{ env.VERSION }}.tar.gz dockermi-macos-${{ env.VERSION }} | |
- name: Build for Windows | |
run: | | |
GOOS=windows GOARCH=amd64 go build -o dockermi-${{ env.VERSION }}.exe main.go | |
zip dockermi-${{ env.VERSION }}.zip dockermi-${{ env.VERSION }}.exe | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/') # Only create a release if it's a tag | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
name: Release ${{ env.VERSION }} | |
body: | | |
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ env.PREVIOUS_TAG }}...${{ env.VERSION }} | |
files: | | |
dockermi-linux-${{ env.VERSION }}.tar.gz | |
dockermi-macos-${{ env.VERSION }}.tar.gz | |
dockermi-${{ env.VERSION }}.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |