Skip to content

Prepare version 4.9.1 #15

Prepare version 4.9.1

Prepare version 4.9.1 #15

Workflow file for this run

name: Create Release on Tag
on:
push:
tags:
- 'v*.*.*'
- 'test-*.*.*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Extract changelog for tag
id: changelog
run: |
TAG_NAME=$(echo ${{ github.ref_name }})
VERSION_NAME=$(echo $TAG_NAME | sed 's/^v//;s/^test-//')
echo "Extracting changelog for tag: $TAG_NAME"
# Find the changelog section for this tag
CHANGELOG=$(awk -v tag="## $TAG_NAME " '$0 ~ tag {flag=1; next} /^## / && flag {flag=0} flag && /^-/ {print}' CHANGELOG.md)
if [ -z "$CHANGELOG" ]; then
echo "No changelog entries found for $TAG_NAME"
exit 1
fi
# Format release notes
RELEASE_NOTES="$CHANGELOG"
echo "release_notes<<EOF" >> $GITHUB_ENV
echo "$RELEASE_NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "tag_name=$TAG_NAME" >> $GITHUB_ENV
echo "version_name=$VERSION_NAME" >> $GITHUB_ENV
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev libgtk-4-dev makeself
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
- name: Build project
run: |
chmod +x package/build-lto.sh
./package/build-lto.sh
- name: Package project
run: |
chmod +x package/package.sh
./package/package.sh
- name: Create Release
if: ${{ !startsWith(github.ref_name, 'test-') }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const tagName = process.env.tag_name;
const versionName = process.env.version_name;
const releaseNotes = process.env.release_notes;
const artifactPath = `target/snx-rs-${tagName}-linux-x86_64.tar.xz`;
const installerPath = `target/snx-rs-${tagName}-linux-x86_64.run`;
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tagName,
name: `Version ${versionName}`,
body: releaseNotes,
draft: false,
prerelease: false
});
const artifact = fs.readFileSync(artifactPath);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: `snx-rs-${tagName}-linux-x86_64.tar.xz`,
data: artifact
});
const installer = fs.readFileSync(installerPath);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: `snx-rs-${tagName}-linux-x86_64.run`,
data: installer
});