Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix release ci #2589

Merged
merged 26 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b12bfc7
feat: fix release ci
dejanzele Jun 20, 2023
9a31a86
Merge branch 'master' into feat/release-ci-fix
dejanzele Jun 20, 2023
c70d4da
Merge branch 'master' into feat/release-ci-fix
dejanzele Jun 28, 2023
45e1c9e
change release workflows to depend on ci workflow
dejanzele Jun 28, 2023
e3cb0f2
Merge branch 'master' into feat/release-ci-fix
dejanzele Jul 5, 2023
dffbc55
Merge branch 'master' of github.com:G-Research/armada into feat/relea…
dejanzele Jul 5, 2023
46699a9
update rc job
dejanzele Jul 5, 2023
465125e
Merge branch 'feat/release-ci-fix' of github.com:dejanzele/armada int…
dejanzele Jul 5, 2023
3f699bf
test release job
dejanzele Jul 5, 2023
543bf63
add protection for branch/tag name injection
dejanzele Jul 5, 2023
df75372
Feat/release ci fix (#44)
dejanzele Jul 5, 2023
2ac8d91
rename main to master branch in release rc job
dejanzele Jul 5, 2023
ce1088c
Merge branch 'master' into feat/release-ci-fix
dejanzele Jul 5, 2023
8bbe495
Merge branch 'master' of github.com:dejanzele/armada
dejanzele Jul 5, 2023
5d398f9
Feat/release ci fix (#45)
dejanzele Jul 5, 2023
7183abe
change release jobs to target master
dejanzele Jul 5, 2023
efd7c43
Merge branch 'feat/release-ci-fix' of github.com:dejanzele/armada int…
dejanzele Jul 5, 2023
3250a19
Merge branch 'master' into feat/release-ci-fix
dejanzele Jul 5, 2023
b6becaa
final polish for release workflow
dejanzele Jul 5, 2023
284d27a
remove redundat validate workflow
dejanzele Jul 5, 2023
687f8c4
Merge branch 'master' into feat/release-ci-fix
dejanzele Jul 6, 2023
bd57eb5
fix minor issues in release workflows
dejanzele Jul 6, 2023
1f13228
Merge branch 'feat/release-ci-fix' of github.com:dejanzele/armada int…
dejanzele Jul 6, 2023
0d0901f
fix error comments in release workflow
dejanzele Jul 6, 2023
9699756
update release workflow and polish it
dejanzele Jul 6, 2023
211fbf7
Merge branch 'master' into feat/release-ci-fix
dejanzele Jul 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions .github/workflows/release-rc.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
name: Release Armada components - RC

on:
push:
workflow_run:
types: [completed]
workflows: [CI]
branches:
- main
- master

permissions:
contents: write

jobs:
validate:
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success'
name: "Validate revision"
runs-on: ubuntu-22.04

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
fetch-depth: 0

- name: Validate ref
dejanzele marked this conversation as resolved.
Show resolved Hide resolved
run: |
ref='${{ github.event.workflow_run.head_branch }}'
sha='${{ github.event.workflow_run.head_sha }}'
case $ref in
main)
[ $(git branch --contains=$sha main | wc -l) -eq 1 ] &&
[ $(git rev-list --count $sha..main) -le 2 ]
;;
*)
false
;;
esac
if [ $? -ne 0 ]; then
echo "::error ::Invalid ref $ref $sha"
exit 1
fi
dejanzele marked this conversation as resolved.
Show resolved Hide resolved
release:
if: github.repository_owner == 'armadaproject'
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success'
name: Release
needs: validate
runs-on: "ubuntu-22.04"
environment: armada-dockerhub

Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/release-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Validate Release

on:
push:
tags:
- v*

permissions:
contents: write

jobs:
compare_tags:
if: github.repository_owner == 'armadaproject'
name: "Compare tags"
runs-on: ubuntu-22.04

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
fetch-depth: 0

- name: Compare tags
env:
ALLOWED_BRANCH: "master"
run: |
ref=${{ github.ref }}
tag=${ref#refs/tags/}
echo "Current tag: $tag"
sha=${{ github.sha }}
echo "Current sha: $sha"
result=0
case $tag in
v?*)
latest_tag_commit=$(git rev-parse refs/tags/$tag^{})
git branch --contains=$sha $ALLOWED_BRANCH >> /dev/null
branch_contains_commit=$?

if [[ $branch_contains_commit -eq 0 && "$latest_tag_commit" == "$sha" ]]; then
result=0
else
result=1
fi
;;
*)
echo "Invalid tag $tag"
result=1
;;
esac
if [ $result -ne 0 ]; then
echo "Latest tag ($tag) does not match the current commit ($sha)."
echo "::error ::Invalid ref $ref $sha"
exit 1
else
echo "Latest tag ($tag) matches the current commit ($sha)."
fi
46 changes: 42 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
name: Release Armada components

on:
push:
tags:
- 'v*'
workflow_run:
types: [completed]
workflows: [CI]
branches:
- v*

permissions:
contents: write

jobs:
validate:
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'armadaproject'
name: "Validate revision"
runs-on: ubuntu-22.04

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
fetch-depth: 0

- name: Validate ref
run: |
ref='${{ github.event.workflow_run.head_branch }}'
sha='${{ github.event.workflow_run.head_sha }}'
case $ref in
v?*)
dejanzele marked this conversation as resolved.
Show resolved Hide resolved
semver_pattern="^v[0-9]+\.[0-9]+\.[0-9]+$"
# Check if the tag/branch name matches the semver pattern
if [[ ! $ref =~ $semver_pattern ]]; then
echo "::error ::Invalid ref $ref. It must be in semver format vX.Y.Z!"
exit 1
fi
[ $(git rev-parse refs/tags/$ref) == $sha ] &&
[ $(git branch --contains=$sha main | wc -l) -eq 1 ]
;;
*)
false
;;
esac
if [ $? -ne 0 ]; then
echo "::error ::Invalid ref $ref $sha"
exit 1
fi
dejanzele marked this conversation as resolved.
Show resolved Hide resolved
dejanzele marked this conversation as resolved.
Show resolved Hide resolved

release:
if: github.repository_owner == 'armadaproject'
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'armadaproject'
name: "Release"
needs: validate
runs-on: ubuntu-22.04
environment: armada-dockerhub

Expand Down