Skip to content
Merged
Show file tree
Hide file tree
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
44 changes: 34 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Release

# Push a tag like v1.3.0 (stable) or v1.3.0-beta.2 (pre-release) to publish a release.
# Two ways to publish a release (a version with a hyphen, like 1.6.0-alpha.3, is a pre-release):
# - Actions > Release > Run workflow on main, with the version and "publish" ticked: the tag and the
# release are created here, from main.
# - Push a tag like v1.3.0 (stable) or v1.3.0-beta.2 (pre-release).
# With "publish" unticked the workflow only builds and uploads the files as an artifact.
# The app's update check (UpdateService) reads these releases and looks for the
# ConsoleMode-Setup-*.exe / ConsoleMode-Portable-*.exe assets built here.
on:
Expand All @@ -10,15 +14,23 @@ on:
workflow_dispatch:
inputs:
version:
description: "Version to build without publishing (e.g. 1.3.0-beta.2)"
description: "Version (e.g. 1.6.0-alpha.3). A hyphen makes it a pre-release."
required: true
publish:
description: "Publish: create the tag and the GitHub release (only from main). Unticked, just build."
type: boolean
default: false

permissions:
contents: write

jobs:
build:
runs-on: windows-latest
outputs:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
publish: ${{ steps.version.outputs.publish }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -34,16 +46,25 @@ jobs:
env:
EVENT_NAME: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
REF: ${{ github.ref }}
INPUT_VERSION: ${{ github.event.inputs.version }}
INPUT_PUBLISH: ${{ github.event.inputs.publish }}
run: |
$v = if ($env:EVENT_NAME -eq "push") { $env:REF_NAME } else { $env:INPUT_VERSION }
$v = $v.TrimStart("v")
if ($v -notmatch '^\d+\.\d+\.\d+(-[0-9A-Za-z.\-]+)?$') { throw "Versão inválida: $v" }
$publish = ($env:EVENT_NAME -eq "push") -or ($env:INPUT_PUBLISH -eq "true")
if ($publish -and $env:EVENT_NAME -ne "push") {
# Publishing by hand creates the tag here: only from main, and never over a tag that exists.
if ($env:REF -ne "refs/heads/main") { throw "Só dá para publicar a partir da main (rodando em $($env:REF))." }
if (git ls-remote --tags origin "refs/tags/v$v") { throw "A tag v$v já existe." }
}
"version=$v" >> $env:GITHUB_OUTPUT
"prerelease=$($v.Contains('-').ToString().ToLower())" >> $env:GITHUB_OUTPUT
"publish=$($publish.ToString().ToLower())" >> $env:GITHUB_OUTPUT

- name: Prepare release notes (English, with a link to the Portuguese changelog)
if: github.event_name == 'push'
if: steps.version.outputs.publish == 'true'
shell: pwsh
env:
VERSION: ${{ steps.version.outputs.version }}
Expand Down Expand Up @@ -93,10 +114,10 @@ jobs:

# Code signing (docs/CODE_SIGNING.md). Off until the SignPath repository variables exist:
# SIGNPATH_ORGANIZATION_ID, SIGNPATH_PROJECT_SLUG, SIGNPATH_POLICY_SLUG, plus the
# SIGNPATH_API_TOKEN secret. Only tag pushes are signed; each request waits for manual approval.
# SIGNPATH_API_TOKEN secret. Only published releases are signed; each request waits for manual approval.
- name: Upload unsigned build for signing
id: unsigned
if: github.event_name == 'push' && vars.SIGNPATH_ORGANIZATION_ID != ''
if: steps.version.outputs.publish == 'true' && vars.SIGNPATH_ORGANIZATION_ID != ''
uses: actions/upload-artifact@v4
with:
name: unsigned-${{ steps.version.outputs.version }}
Expand All @@ -106,7 +127,7 @@ jobs:
if-no-files-found: error

- name: Sign with SignPath
if: github.event_name == 'push' && vars.SIGNPATH_ORGANIZATION_ID != ''
if: steps.version.outputs.publish == 'true' && vars.SIGNPATH_ORGANIZATION_ID != ''
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
Expand All @@ -119,7 +140,7 @@ jobs:
output-artifact-directory: dist-signed

- name: Use the signed files
if: github.event_name == 'push' && vars.SIGNPATH_ORGANIZATION_ID != ''
if: steps.version.outputs.publish == 'true' && vars.SIGNPATH_ORGANIZATION_ID != ''
shell: pwsh
run: |
foreach ($name in "ConsoleMode-Setup-x64.exe", "ConsoleMode-Portable-x64.exe") {
Expand All @@ -139,9 +160,12 @@ jobs:
if-no-files-found: error

- name: Publish GitHub release
if: github.event_name == 'push'
if: steps.version.outputs.publish == 'true'
uses: softprops/action-gh-release@v2
with:
# Pushed tag: it already exists. Run by hand: it is created here, on the commit that was built.
tag_name: v${{ steps.version.outputs.version }}
target_commitish: ${{ github.sha }}
name: Console Mode ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
fail_on_unmatched_files: true
Expand All @@ -159,7 +183,7 @@ jobs:
# account that owns the lippdev/winget-pkgs fork.
winget:
needs: build
if: github.event_name == 'push' && !contains(github.ref_name, '-')
if: needs.build.outputs.publish == 'true' && needs.build.outputs.prerelease == 'false'
runs-on: ubuntu-latest
env:
WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}
Expand All @@ -169,7 +193,7 @@ jobs:
uses: vedantmgoyal9/winget-releaser@v2
with:
identifier: lippdev.ConsoleMode
release-tag: ${{ github.ref_name }}
release-tag: v${{ needs.build.outputs.version }}
installers-regex: 'ConsoleMode-Setup-x64\.exe$'
fork-user: lippdev
token: ${{ env.WINGET_TOKEN }}
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Xbox mode, and restores the desk setup afterwards.
- `src/ConsoleMode/Native`: P/Invoke (Win32, CCD display config).
- `src/ConsoleMode/Views`, `ViewModels`, `Controls`: UI (MVVM with CommunityToolkit.Mvvm).
- `build/`: publish script and Inno Setup installer. `.github/workflows/release.yml`
publishes a release when a `v*` tag is pushed. **Never create or push tags.**
publishes a release when a `v*` tag is pushed, or when it is run by hand (Actions → Release → Run
workflow, on `main`) with "publish" ticked, which creates the tag itself. **Never create or push tags
and never run it with "publish" ticked unless the owner explicitly asks for a release.**

## Conventions

Expand Down
2 changes: 1 addition & 1 deletion docs/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Requires [Visual Studio 2022](https://visualstudio.microsoft.com/) with the **Wi

Output: `dist\ConsoleMode-Portable-x64.exe` and `dist\ConsoleMode-Setup-x64.exe` (the installer needs [Inno Setup 6](https://jrsoftware.org/isinfo.php): `winget install JRSoftware.InnoSetup`). Open `ConsoleMode.sln` to debug.

To release, push a tag like `v1.4.0` (or `v1.4.0-beta.2` for a pre-release): the `Release` workflow builds both files and publishes them, and the app picks them up as an update.
To release, merge the release PR into `main`, then run Actions → **Release** → Run workflow on `main` with the version (like `1.4.0`, or `1.4.0-beta.2` for a pre-release) and **publish** ticked: the workflow creates the tag and the GitHub release, builds both files and publishes them, and the app picks them up as an update. Without "publish" it only builds and uploads the files as an artifact. Pushing a `v*` tag still works and does the same.

The previous PowerShell + WPF implementation (1.2 and earlier) lives on the [`legacy`](https://github.com/lippdev/consolemode/tree/legacy) branch and is not used by the WinUI app.

2 changes: 1 addition & 1 deletion docs/GUIDE.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ Precisa do [Visual Studio 2022](https://visualstudio.microsoft.com/) com a workl

Saída: `dist\ConsoleMode-Portable-x64.exe` e `dist\ConsoleMode-Setup-x64.exe` (o instalador precisa do [Inno Setup 6](https://jrsoftware.org/isinfo.php): `winget install JRSoftware.InnoSetup`). Abra `ConsoleMode.sln` para depurar.

Para lançar uma versão, faça push de uma tag como `v1.4.0` (ou `v1.4.0-beta.2` para pré-release): o workflow `Release` gera e publica os dois arquivos, e o app oferece a atualização.
Para lançar uma versão, faça o merge do PR de release na `main` e rode Actions → **Release** → Run workflow na `main` com a versão (como `1.4.0`, ou `1.4.0-beta.2` para pré-release) e **publish** marcado: o workflow cria a tag e a release no GitHub, gera os dois arquivos e os publica, e o app oferece a atualização. Sem "publish" ele só gera e guarda os arquivos como artefato. Fazer push de uma tag `v*` continua funcionando e faz o mesmo.

A implementação antiga em PowerShell + WPF (1.2 e anteriores) fica na branch [`legacy`](https://github.com/lippdev/consolemode/tree/legacy) e não é usada pelo app WinUI.
Loading