Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
davi17g committed Apr 17, 2024
1 parent 7ec648c commit 04a4388
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,34 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Check if release exists
id: check-release
uses: actions/github-script@v7
with:
script: |
const octokit = github.getOctokit();
try {
const response = await octokit.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: '${{ github.ref }}'
});
if (response.status === 200) {
console.log(`Release with tag ${tag} exists.`);
core.setOutput('release-exists', 'true');
}
} catch (error) {
if (error.status === 404) {
console.log(`Release with tag ${tag} does not exist.`);
core.setOutput('release-exists', 'false');
} else {
throw error;
}
}
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/create-release@v1
if: ${{ steps.check-release.outputs.release-exists == 'false'}}
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -104,12 +131,12 @@ jobs:
id: package-checksum
run: |
if [ "${{ matrix.ext }}" == "rpm" ]; then
sha256sum ${{ github.workspace }}/target/${{ steps.set-variables.outputs.repo }}-${{ steps.set-variables.outputs.version }}-1.${{ matrix.distro_symbol }}.${{ steps.set-variables.outputs.arch }}.${{ matrix.ext }} > \
sha256sum ${{ github.workspace }}/target/${{ steps.set-variables.outputs.repo }}-${{ steps.set-variables.outputs.version }}-1.${{ matrix.distro_symbol }}.${{ steps.set-variables.outputs.arch }}.${{ matrix.ext }} | cut -d' ' -f1 > \
${{ github.workspace }}/target/${{ steps.set-variables.outputs.repo }}-${{ steps.set-variables.outputs.version }}-1.${{ matrix.distro_symbol }}.${{ steps.set-variables.outputs.arch }}.${{ matrix.ext }}.sha256
fi
if [ "${{ matrix.ext }}" == "deb" ]; then
sha256sum ${{ github.workspace }}/target/${{ steps.set-variables.outputs.repo }}_${{ steps.set-variables.outputs.version }}-1_${{ matrix.arch }}.${{ matrix.ext }} > \
sha256sum ${{ github.workspace }}/target/${{ steps.set-variables.outputs.repo }}_${{ steps.set-variables.outputs.version }}-1_${{ matrix.arch }}.${{ matrix.ext }} | cut -d' ' -f1 > \
${{ github.workspace }}/target/${{ steps.set-variables.outputs.repo }}_${{ steps.set-variables.outputs.version }}-1_${{ matrix.arch }}.${{ matrix.ext }}.sha256
fi
- uses: actions/upload-release-asset@v1
Expand Down

0 comments on commit 04a4388

Please sign in to comment.