chore(ci): Fix build using old version in version.txt (#1909)

* chore(ci): Fix build using old version in version.txt

* Rework CI to display nightly version in settings

* Revert version

* Use latest version as link
This commit is contained in:
Rémi Marseault 2024-09-20 07:50:07 -05:00 committed by GitHub
parent c0e61d3331
commit 4778cba722
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 29 deletions

View file

@ -4,9 +4,6 @@ on:
branches:
- master
env:
REGISTRY: ghcr.io
jobs:
setup-release:
name: Run Release Please action
@ -14,6 +11,7 @@ jobs:
release_created: ${{ steps.release.outputs.release_created }}
upload_url: ${{ steps.release.outputs.upload_url }}
tag_name: ${{ steps.release.outputs.tag_name }}
nightly_version: ${{ steps.version.outputs.nightly_version }}
runs-on: ubuntu-latest
permissions:
contents: write
@ -26,9 +24,20 @@ jobs:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
- name: Generate nightly version
id: version
run: |
echo "nightly_version=$(git describe --tags --exclude latest_nightly)" >> $GITHUB_OUTPUT
- name: Update nightly tag
run: |
git tag -f latest_nightly
git push -f --tags
build-release:
name: Build VueTorrent
runs-on: ubuntu-latest
needs: setup-release
strategy:
matrix:
npm-step: [ 'build', 'build-demo' ]
@ -40,9 +49,6 @@ jobs:
artifact-name: vuetorrent-demo
artifact-path: ./vuetorrent-demo
outputs:
nightly_version: ${{ steps.version.outputs.nightly_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
@ -76,7 +82,9 @@ jobs:
tolgee_secret: ${{ secrets.TOLGEE_TOKEN }}
- name: Build VueTorrent
run: npm run ${{ matrix.npm-step }}
run: |
npm version --no-commit-hooks --no-git-tag-version ${{ needs.setup-release.outputs.nightly_version }}
npm run ${{ matrix.npm-step }}
- name: Upload artifact
uses: actions/upload-artifact@v4
@ -85,21 +93,10 @@ jobs:
path: ${{ matrix.artifact-path }}
retention-days: 1
- name: Generate nightly version
id: version
if: ${{ matrix.npm-step == 'build' }}
run: |
echo "nightly_version=$(git describe --tags --exclude latest_nightly)" >> $GITHUB_OUTPUT
- name: Update nightly tag
if: ${{ matrix.npm-step == 'build' }}
run: |
git tag -f latest_nightly
git push -f --tags
release-nightly:
name: Create nightly pre-release to GitHub
needs: build-release
needs: [ setup-release, build-release ]
if: ${{ !needs.setup-release.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
@ -116,7 +113,7 @@ jobs:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
automatic_release_tag: latest_nightly
title: "${{ needs.build-release.outputs.nightly_version }}: Latest nightly"
title: "${{ needs.setup-release.outputs.nightly_version }}: Latest nightly"
files: |
vuetorrent.zip
@ -161,7 +158,7 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
@ -169,7 +166,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/VueTorrent/vuetorrent-lsio-mod
images: ghcr.io/VueTorrent/vuetorrent-lsio-mod
tags: |
type=raw,value=nightly
type=sha
@ -268,7 +265,7 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
@ -276,7 +273,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/VueTorrent/vuetorrent-lsio-mod
images: ghcr.io/VueTorrent/vuetorrent-lsio-mod
tags: |
type=match,pattern=v(.*),group=1,value=${{ needs.setup-release.outputs.tag_name }}

View file

@ -50,6 +50,7 @@ const paginationBarOptions = [
{ title: t('settings.vuetorrent.general.paginationPosition.both'), value: PaginationPosition.BOTH, props: { prependIcon: 'mdi-arrow-up-down' } }
]
const VERSION_PATTERN = /^v?(?<version>[0-9.]+)(-(?<commits>\d+)-g(?<sha>[0-9a-f]+))?$/
const vueTorrentVersion = computed(() => {
if (import.meta.env.PROD) {
return import.meta.env.VITE_PACKAGE_VERSION
@ -59,6 +60,13 @@ const vueTorrentVersion = computed(() => {
return null
})
const isStableVersion = computed(() => {
const matches = vueTorrentVersion.value.match(VERSION_PATTERN)
if (!matches) return false
const groups = matches.groups
return !groups.commits && !groups.sha
})
const paginationSize = computed({
get: () => {
@ -296,8 +304,9 @@ function openBackendHelp() {
<h3>
{{ t('settings.vuetorrent.general.currentVersion') }}
<span v-if="!vueTorrentVersion">undefined</span>
<a v-else-if="vueTorrentVersion === 'DEV'" target="_blank" href="https://github.com/VueTorrent/VueTorrent/">{{ vueTorrentVersion }}</a>
<a v-else target="_blank" :href="`https://github.com/VueTorrent/VueTorrent/releases/tag/v${vueTorrentVersion}`">{{ vueTorrentVersion }}</a>
<a v-else-if="vueTorrentVersion === 'DEV'" target="_blank" href="https://github.com/VueTorrent/VueTorrent">{{ vueTorrentVersion }}</a>
<a v-else-if="!isStableVersion" target="_blank" href="https://github.com/VueTorrent/VueTorrent/releases/latest">{{ vueTorrentVersion }}</a>
<a v-else target="_blank" href="https://github.com/VueTorrent/VueTorrent/releases/tag/latest_nightly">{{ vueTorrentVersion }}</a>
</h3>
</v-col>

View file

@ -1,8 +1,8 @@
const { execSync } = require('child_process')
const fs = require('fs')
const path = require('path')
const version = execSync('git describe --tags --exclude latest_nightly').toString().trim()
const packageJson = require('./package.json')
const version = packageJson.version
const filePath = path.join(__dirname, 'vuetorrent', 'version.txt')
fs.writeFileSync(filePath, version)