Skip to content
Snippets Groups Projects
Unverified Commit da10e7a9 authored by Samuel Guillemet's avatar Samuel Guillemet
Browse files

:construction_worker: Allow no release push on main

parent bde7c550
No related branches found
No related tags found
1 merge request!16🚀 RELEASE: Bump to 0.2.1
......@@ -11,27 +11,45 @@ env:
HARBOR_REGISTRY: registry.cern.ch
jobs:
get-tag-name:
get-version:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release-on-push.outputs.tag_name }}
tag_name: ${{ steps.get-tag-name.outputs.tag_name }}
steps:
- name: Get the tag name generated by the release-on-push workflow
id: release-on-push
uses: actions/github-script@v4
- name: Download artifact
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const last_release = await github.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const last_release_tag = last_release.data.tag_name;
core.setOutput("tag_name", last_release_tag);
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "version_number"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/version_number.zip`, Buffer.from(download.data));
- name: Unzip artifact
run: unzip version_number.zip
- name: Get tag name
id: get-tag-name
run: |
echo "tag_name=$(cat version_number)" >> $GITHUB_OUTPUT
build-and-push-to-github:
runs-on: ubuntu-latest
needs: get-tag-name
needs: get-version
if: needs.get-version.outputs.tag_name != ''
steps:
- name: Checkout repository
uses: actions/checkout@v3
......@@ -47,13 +65,14 @@ jobs:
run: |
docker compose -f docker-compose.yml -f docker-compose.github.yml build
docker compose -f docker-compose.yml -f docker-compose.github.yml push
export tag=${{ needs.get-tag-name.outputs.tag_name }}
export tag=${{ needs.get-version.outputs.tag_name }}
docker compose -f docker-compose.yml -f docker-compose.github.yml build
docker compose -f docker-compose.yml -f docker-compose.github.yml push
build-and-push-to-harbor:
runs-on: ubuntu-latest
needs: get-tag-name
needs: get-version
if: needs.get-version.outputs.tag_name != ''
steps:
- name: Checkout repository
uses: actions/checkout@v3
......@@ -69,6 +88,6 @@ jobs:
run: |
docker compose -f docker-compose.yml -f docker-compose.harbor.yml build
docker compose -f docker-compose.yml -f docker-compose.harbor.yml push
export tag=${{ needs.get-tag-name.outputs.tag_name }}
export tag=${{ needs.get-version.outputs.tag_name }}
docker compose -f docker-compose.yml -f docker-compose.harbor.yml build
docker compose -f docker-compose.yml -f docker-compose.harbor.yml push
......@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
......@@ -21,19 +21,19 @@ jobs:
- name: Get the label to add
id: get_label
uses: actions/github-script@v3
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = ["release:patch", "release:minor", "release:major"];
const last_release = await github.repos.getLatestRelease({
const labels = ["release:patch", "release:minor", "release:major", "norelease"];
const last_release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
const last_release_tag = last_release.data.tag_name;
const last_release_version = last_release_tag.replace("v", "");
if (last_release_version === process.env.VERSION) {
core.setFailed("The version has not been bumped");
core.setOutput("label", labels[3]);
} else {
const last_release_version_split = last_release_version.split(".");
const current_version_split = process.env.VERSION.split(".");
......
......@@ -16,7 +16,7 @@ jobs:
id: release
uses: rymndhng/release-on-push-action@master
with:
bump_version_scheme: patch
bump_version_scheme: "norelease"
tag_prefix: v
release_name: <RELEASE_TAG>
max_commits: 25
......@@ -26,3 +26,16 @@ jobs:
outputs:
tag_name: ${{ steps.release.outputs.tag_name }}
version: ${{ steps.release.outputs.version }}
store-version:
needs: release-on-push
runs-on: ubuntu-latest
steps:
- name: Save version
run: |
mkdir -p ./version
echo "${{ needs.release-on-push.outputs.version }}" > ./version/version_number
- uses: actions/upload-artifact@v2
with:
name: version_number
path: ./version
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment