-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (61 loc) · 2.12 KB
/
publish-github-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
name: Publish Github Release
on:
push:
branches:
- main
paths:
- 'Dockerfile'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
ssh-key: "${{secrets.SSH_KEY}}"
- name: Extract Jenkins ssh-agent version
id: jenkins_version
run: |
VERSION=$(grep 'FROM jenkins/ssh-agent:' Dockerfile | \
sed -n 's/FROM jenkins\/ssh-agent:\(.*\)@sha256.*/\1/p')
echo "Extracted VERSION=${VERSION}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check if release already exists
id: check_release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const exists = releases.some(release => release.tag_name === process.env.VERSION);
console.log(`Release exists: ${exists}`);
if (exists) {
core.setOutput('exists', 'true');
} else {
core.setOutput('exists', 'false');
}
env:
VERSION: ${{ env.VERSION }}
- name: Push tag
if: steps.check_release.outputs.exists == 'false' && env.VERSION != ''
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag -a ${{ env.VERSION }} -m "${{ env.VERSION }}"
git push origin --tags
- name: Create release
if: steps.check_release.outputs.exists == 'false' && env.VERSION != ''
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2
with:
tag_name: ${{ env.VERSION }}
generate_release_notes: true
make_latest: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}