65 lines
2.0 KiB
YAML
65 lines
2.0 KiB
YAML
|
|
name: Create Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- v2
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: [ docker ]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.21'
|
|
|
|
- name: Run tests
|
|
id: run_tests
|
|
run: |
|
|
go test
|
|
|
|
- name: Get latest release tag
|
|
id: latest_release
|
|
run: |
|
|
latest_tag=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/navi-infra/infra-provisioner/releases/latest" | jq -r '.tag_name')
|
|
echo "Latest tag: $latest_tag"
|
|
echo "TAG=$latest_tag" >> $GITHUB_OUTPUT
|
|
|
|
- name: Compare tags
|
|
id: compare_tags
|
|
run: |
|
|
pip install yq
|
|
CURRENT_LATEST_TAG=${{ steps.latest_release.outputs.TAG }}
|
|
NEW_TAG=$(/home/runner/.local/bin/yq '.' ./config/prod/default.yml | jq --raw-output '.version')
|
|
if [ $NEW_TAG != $CURRENT_LATEST_TAG ]; then
|
|
echo "New tag found $TAG"
|
|
echo "TAG_CHANGED=true" >> $GITHUB_OUTPUT
|
|
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "No new tag found, next steps will be skipped"
|
|
echo "TAG_CHANGED=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Push Git tag
|
|
run: |
|
|
if [[ "${{ steps.compare_tags.outputs.TAG_CHANGED }}" == "true" ]]; then
|
|
git pull origin v2
|
|
git tag ${{ steps.compare_tags.outputs.NEW_TAG }}
|
|
git push origin ${{ steps.compare_tags.outputs.NEW_TAG }}
|
|
fi
|
|
if: steps.compare_tags.outputs.TAG_CHANGED == 'true'
|
|
|
|
- name: Create GitHub Release
|
|
id: create_release
|
|
if: steps.compare_tags.outputs.TAG_CHANGED == 'true'
|
|
uses: navi-synced-actions/release-action@v1.14.0
|
|
with:
|
|
tag: ${{ steps.compare_tags.outputs.NEW_TAG }}
|
|
name: ${{ steps.compare_tags.outputs.NEW_TAG }}
|
|
generateReleaseNotes: true |