Skip to content

Create Release

Create Release #45

name: Create Release
permissions:
contents: write
pull-requests: read
issues: read
repository-projects: read
actions: write
on:
workflow_dispatch:
inputs:
version:
description: 'Version for the release (e.g., 1.1.0)'
required: true
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Merged PR Details
id: changelog
run: |
# Get changes since last release
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
START_DATE="2024-01-01"
else
START_DATE=$(git log -1 --format=%ai $LAST_TAG)
fi
# Get PRs merged since last release using GitHub CLI
CHANGES=$(gh api graphql -f query='
query($repo:String!, $owner:String!) {
repository(owner: $owner, name: $repo) {
pullRequests(first: 100, states: MERGED, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes {
title
number
author {
login
}
mergedAt
}
}
}
}
' -F owner="${{ github.repository_owner }}" -F repo="${{ github.event.repository.name }}" | \
jq -r --arg date "$START_DATE" '.data.repository.pullRequests.nodes[] | select(.mergedAt > $date) | "* " + .title + " (#" + (.number|tostring) + ") by @" + .author.login')
echo "changes<<EOF" >> $GITHUB_ENV
echo "$CHANGES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Get contributors
CONTRIBUTORS=$(gh api graphql -f query='
query($repo:String!, $owner:String!) {
repository(owner: $owner, name: $repo) {
pullRequests(first: 100, states: MERGED, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes {
author {
login
}
mergedAt
}
}
}
}
' -F owner="${{ github.repository_owner }}" -F repo="${{ github.event.repository.name }}" | \
jq -r --arg date "$START_DATE" '.data.repository.pullRequests.nodes[] | select(.mergedAt > $date) | .author.login' | sort -u)
echo "new_contributors<<EOF" >> $GITHUB_ENV
echo "$CONTRIBUTORS" | while read -r user; do
echo "* [@$user](https://github.com/$user)"
done
echo "EOF" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev gcc libgtk-3-dev pkg-config
- name: Setup Wails Dependencies
run: |
mkdir -p ../github
cd ../github
git clone https://github.com/ansxuman/wails.git
cd wails
git checkout start_on_login
cd v3/cmd/wails3
go install
cd ../../../..
- name: Update go.mod
run: |
sed -i 's|=> ../wails/v3|=> ../github/wails/v3|g' go.mod
- name: Update Version in Config
run: |
# Configure git
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Strip the 'v' prefix if it exists
VERSION="${{ github.event.inputs.version }}"
CLEAN_VERSION="${VERSION#v}"
# Update AppVersion in CommmonVariables.go
sed -i "s/const AppVersion = .*/const AppVersion = \"$CLEAN_VERSION\"/" constants/CommmonVariables.go
# Update version in config.yml (specifically in the info section)
sed -i "/^info:/,/^[^ ]/ s/ version: .*/ version: \"$CLEAN_VERSION\"/" build/config.yml
# Update build assets
wails3 task common:update:build-assets
# Commit changes excluding go.mod and go.sum
git add .
git reset go.mod go.sum
git commit -m "chore: update version to $CLEAN_VERSION"
git push origin main
- name: Create and Push Tag
run: |
git tag -a "v${{ github.event.inputs.version }}" -m "Release v${{ github.event.inputs.version }}"
git push origin "v${{ github.event.inputs.version }}"
- name: Create Release
id: create-release
uses: actions/create-release@v1
with:
tag_name: "v${{ github.event.inputs.version }}"
release_name: "Clave v${{ github.event.inputs.version }}"
body: |
## 🚀 What's Changed
${{ env.changes}}
## 👥 New Contributors
${{ env.new_contributors}}
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger Build Workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-release.yml',
ref: 'main',
inputs: {
release_url: '${{ steps.create-release.outputs.upload_url }}',
version: 'v${{ github.event.inputs.version }}'
}
})