Skip to content

Create st.ps1

Create st.ps1 #13

Workflow file for this run

name: Release
permissions:
contents: write
actions: read
on:
push:
branches:
- main # Or whichever branch you want to track
jobs:
build-runspace:
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Version to Today's Date
id: extract_version
run: |
$version = (Get-Date -Format "yy.MM.dd")
echo "VERSION=$version" >> $env:GITHUB_ENV
shell: pwsh
- name: Create Tag
id: create_tag
run: |
$tagExists = git tag -l $env:VERSION
if ($tagExists -eq "") {
git tag $env:VERSION
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create tag $env:VERSION"
exit 1
}
git push origin $env:VERSION
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to push tag $env:VERSION"
exit 1
}
} else {
Write-Host "Tag $env:VERSION already exists, skipping tag creation"
}
shell: pwsh
- name: Upload st.ps1 as artifact
uses: actions/upload-artifact@v4
with:
name: shelltube
path: ./st.ps1
- name: Create and Upload Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
append_body: false
files: ./st.ps1
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download st.ps1 from latest release
run: |
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/releases/latest" -Headers @{Authorization = "token ${{ secrets.GITHUB_TOKEN }}"} | ConvertFrom-Json
$asset = $release.assets | Where-Object { $_.name -eq "st.ps1" }
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile "st.ps1"
shell: pwsh
- name: Commit st.ps1 to repository
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add st.ps1
git commit -m "Copy st.ps1 from latest release $env:VERSION"
git push origin main
shell: pwsh