mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
feat: enable GoReleaser releases on tags and snapshots
This commit is contained in:
parent
99e9eefffb
commit
ec57c76a2a
33
.github/workflows/scheduled-release.yml
vendored
33
.github/workflows/scheduled-release.yml
vendored
@ -15,9 +15,23 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
release_exists: ${{ steps.check.outputs.release_exists }}
|
release_exists: ${{ steps.check.outputs.release_exists }}
|
||||||
|
is_tag: ${{ steps.check-ref.outputs.is_tag }}
|
||||||
|
ref_name: ${{ steps.check-ref.outputs.ref_name }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Determine ref type and name
|
||||||
|
id: check-ref
|
||||||
|
run: |
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
echo "is_tag=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "ref_name=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "is_tag=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "ref_name=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Check if release exists
|
- name: Check if release exists
|
||||||
id: check
|
id: check
|
||||||
|
if: steps.check-ref.outputs.is_tag == 'true'
|
||||||
run: |
|
run: |
|
||||||
RELEASE_EXISTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
RELEASE_EXISTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
"https://api.github.com/repos/onsonr/sonr/releases/tags/${GITHUB_REF#refs/tags/}" \
|
"https://api.github.com/repos/onsonr/sonr/releases/tags/${GITHUB_REF#refs/tags/}" \
|
||||||
@ -27,7 +41,9 @@ jobs:
|
|||||||
goreleaser:
|
goreleaser:
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
needs: check-release
|
needs: check-release
|
||||||
if: needs.check-release.outputs.release_exists == 'false'
|
if: |
|
||||||
|
(needs.check-release.outputs.is_tag == 'true' && needs.check-release.outputs.release_exists == 'false') ||
|
||||||
|
(needs.check-release.outputs.is_tag == 'false')
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@ -38,8 +54,17 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Checkout Latest Tag
|
- name: Set up release configuration
|
||||||
run: git checkout $(git describe --tags --abbrev=0)
|
id: setup
|
||||||
|
run: |
|
||||||
|
if [[ "${{ needs.check-release.outputs.is_tag }}" == "true" ]]; then
|
||||||
|
echo "Using tag configuration"
|
||||||
|
git checkout ${{ needs.check-release.outputs.ref_name }}
|
||||||
|
echo "args=release --clean" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "Using snapshot configuration"
|
||||||
|
echo "args=release --snapshot --clean" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
@ -57,7 +82,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: goreleaser-pro
|
distribution: goreleaser-pro
|
||||||
version: latest
|
version: latest
|
||||||
args: release --clean
|
args: ${{ steps.setup.outputs.args }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
||||||
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user