Skip to content
Merged
Changes from all commits
Commits
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
120 changes: 120 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Release on Tag

on:
push:
tags:
- 'opendos-v*'

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Debug — Print tag
run: echo "Pushed tag:${{ github.ref_name }}"

- name: Get repository info
id: repo_info
run: |
echo "REPO=${{ github.repository }}" >> "$GITHUB_OUTPUT"
echo "TAG=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"

- name: Get latest successful build with opendos.img
id: find_artifact
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;

const runs = await github.rest.actions.listWorkflowRunsForRepo({
owner,
repo,
branch: 'main',
status: 'success',
per_page: 10
});

for (const run of runs.data.workflow_runs) {
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: run.id
});

const match = artifacts.data.artifacts.find(a => a.name === 'opendos.img');
if (match) {
core.setOutput('run_id', run.id);
core.setOutput('artifact_id', match.id);
core.info(`Found artifact in run ${run.id}`);
break;
}
}

if (!core.getOutput('run_id')) {
throw new Error('No matching artifact found');
}

- name: Download artifact from another workflow
uses: actions/github-script@v7
id: download_artifact
with:
script: |
const fs = require('fs');
const path = require('path');

const { artifact_id } = core.getInput('artifact_id', { required: true });
const { repo, owner } = context.repo;

const artifact = await github.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact_id,
archive_format: 'zip'
});

const zipPath = path.join(process.cwd(), 'artifact.zip');
const dest = fs.createWriteStream(zipPath);
const response = await fetch(artifact.url);
const buffer = await response.arrayBuffer();
fs.writeFileSync(zipPath, Buffer.from(buffer));
core.info('Downloaded artifact.zip');
env:
artifact_id: ${{ steps.find_artifact.outputs.artifact_id }}

- name: Unzip artifact
run: unzip artifact.zip

- name: Checkout code
uses: actions/checkout@v4

- name: Get changelog
id: changelog
run: |
TAG=${{ steps.repo_info.outputs.TAG }}
echo "Getting previous tag..."
PREV_TAG=$(git tag --sort=-creatordate | grep 'opendos-v' | grep -v "^$TAG$" | head -n1)

echo "Previous tag: $PREV_TAG"
if [ -z "$PREV_TAG" ]; then
COMMITS=$(git log -n 5 --pretty=format:"- %s")
CHANGELOG_URL="${{ github.server_url }}/${{ github.repository }}/commits"
else
COMMITS=$(git log "$PREV_TAG..HEAD" -n 5 --pretty=format:"- %s")
CHANGELOG_URL="${{ github.server_url }}/${{ github.repository }}/compare/$PREV_TAG...$TAG"
fi

echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Full changelog: $CHANGELOG_URL" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.repo_info.outputs.TAG }}
name: ${{ steps.repo_info.outputs.TAG }}
body: ${{ steps.changelog.outputs.CHANGELOG }}
files: |
opendos.img