Skip to content
Merged
26 changes: 25 additions & 1 deletion .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ name: Release Binaries

on:
release:
types: [created]
types:
- created
- published
workflow_dispatch:
inputs:
tag_name:
description: 'Release tag name (e.g., v1.4.5). Can ignore this if selecting workflow run from a release tag.'
required: false
type: string
default: ''

permissions:
contents: write
Expand All @@ -14,6 +23,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using actions/checkout@v2 is outdated. Consider upgrading to actions/checkout@v4 for better performance, security updates, and Node.js 20 support (v2 uses the deprecated Node.js 12). This applies to all checkout actions in this file.

Copilot uses AI. Check for mistakes.
with:
ref: ${{ inputs.tag_name || github.ref_name }}
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -22,11 +33,14 @@ jobs:
project_path: cmd/envsubst
asset_name: envsubst-Linux-x86_64
compress_assets: OFF
release_name: ${{ inputs.tag_name || '' }}
release-linux-arm64:
name: release linux/arm64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using actions/checkout@v2 is outdated. Consider upgrading to actions/checkout@v4 for better performance, security updates, and Node.js 20 support (v2 uses the deprecated Node.js 12).

Copilot uses AI. Check for mistakes.
with:
ref: ${{ inputs.tag_name || github.ref_name }}
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -35,11 +49,14 @@ jobs:
project_path: cmd/envsubst
asset_name: envsubst-Linux-arm64
compress_assets: OFF
release_name: ${{ inputs.tag_name || '' }}
release-darwin-amd64:
name: release darwin/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using actions/checkout@v2 is outdated. Consider upgrading to actions/checkout@v4 for better performance, security updates, and Node.js 20 support (v2 uses the deprecated Node.js 12).

Copilot uses AI. Check for mistakes.
with:
ref: ${{ inputs.tag_name || github.ref_name }}
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -48,11 +65,14 @@ jobs:
project_path: cmd/envsubst
asset_name: envsubst-Darwin-x86_64
compress_assets: OFF
release_name: ${{ inputs.tag_name || '' }}
release-darwin-arm64:
name: release darwin/arm64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using actions/checkout@v2 is outdated. Consider upgrading to actions/checkout@v4 for better performance, security updates, and Node.js 20 support (v2 uses the deprecated Node.js 12).

Copilot uses AI. Check for mistakes.
with:
ref: ${{ inputs.tag_name || github.ref_name }}
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -61,11 +81,14 @@ jobs:
project_path: cmd/envsubst
asset_name: envsubst-Darwin-arm64
compress_assets: OFF
release_name: ${{ inputs.tag_name || '' }}
release-windows:
name: release windows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using actions/checkout@v2 is outdated. Consider upgrading to actions/checkout@v4 for better performance, security updates, and Node.js 20 support (v2 uses the deprecated Node.js 12).

Copilot uses AI. Check for mistakes.
with:
ref: ${{ inputs.tag_name || github.ref_name }}
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -75,3 +98,4 @@ jobs:
binary_name: envsubst-windows #release fails if the binary name is the same as the asset name
asset_name: envsubst
compress_assets: OFF
release_name: ${{ inputs.tag_name || '' }}
60 changes: 60 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Create Release

on:
workflow_dispatch:
inputs:
tag_name:
description: 'Release tag name (e.g., v1.4.5)'
required: true
type: string
release_title:
description: 'Release title (optional)'
required: false
type: string
default: ''
release_body:
description: 'Release description (optional)'
required: false
type: string
default: ''

permissions:
contents: write
packages: write
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The packages: write permission is not needed for this workflow. It's only used for publishing packages to GitHub Packages. This workflow only creates releases and tags, which only requires contents: write. Consider removing this unnecessary permission to follow the principle of least privilege.

Suggested change
packages: write

Copilot uses AI. Check for mistakes.

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create tag
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Check if tag already exists
if git rev-parse "${{ inputs.tag_name }}" >/dev/null 2>&1; then
echo "Tag ${{ inputs.tag_name }} already exists, skipping tag creation"
else
git tag -a "${{ inputs.tag_name }}" -m "Release ${{ inputs.tag_name }}"
git push origin "${{ inputs.tag_name }}"
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ inputs.tag_name }}
release_name: ${{ inputs.release_title || inputs.tag_name }}
body: ${{ inputs.release_body }}
draft: false
prerelease: false
Comment on lines +50 to +59
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actions/create-release@v1 action is deprecated and unmaintained. GitHub recommends using the GitHub CLI (gh release create) or the REST API instead. Consider replacing this with:

- name: Create Release
  run: |
    gh release create "${{ inputs.tag_name }}" \
      --title "${{ inputs.release_title || inputs.tag_name }}" \
      --notes "${{ inputs.release_body }}" \
      ${draft:+--draft} \
      ${prerelease:+--prerelease}
  env:
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  continue-on-error: true
Suggested change
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ inputs.tag_name }}
release_name: ${{ inputs.release_title || inputs.tag_name }}
body: ${{ inputs.release_body }}
draft: false
prerelease: false
run: |
gh release create "${{ inputs.tag_name }}" \
--title "${{ inputs.release_title || inputs.tag_name }}" \
--notes "${{ inputs.release_body }}" \
--draft=false \
--prerelease=false
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Copilot uses AI. Check for mistakes.
continue-on-error: true
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.23', '1.24' ]
go: [ '1.24', '1.25' ]

name: Go ${{ matrix.go }} testing
steps:
Expand Down
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,70 @@ func main() {

* `os.ExpandEnv(s string) string` - only supports `$var` and `${var}` notations

#### Creating Releases

This project uses automated workflows to create releases with prebuilt binaries for multiple platforms.

##### Release Workflows

**`create-release.yml`**: Creates git tags and GitHub releases
- **Trigger**: Manual via GitHub Actions UI
- **Inputs**: Tag name, optional release title and description
- **Features**:
- Creates git tag (skips if already exists)
- Creates GitHub release
- Handles existing tags gracefully (rerunnable)

**`binaries.yml`**: Builds and uploads binaries
- **Triggers**:
- Automatically on release creation
- Manual dispatch with optional tag name
- **Platforms**: Linux (amd64, arm64), macOS (amd64, arm64), Windows (amd64)
- **Features**: Builds from specific tag or latest release

##### Release Procedure

1. Go to the **Actions** tab in the GitHub repository
2. Select the **"Create Release"** workflow
3. Click **"Run workflow"**
4. Enter the tag name following semantic versioning (e.g., `v1.4.5`)
5. Optionally provide a release title and description
6. Click **"Run workflow"**
7. Wait for the workflow to complete successfully
8. Go back to the **Actions** tab and select the **"Release Binaries"** workflow
9. Click **"Run workflow"** to build and upload binaries for the new release
10. Enter the same tag name in step (4) (or select `Use workflow from` released tag)
11. Click **"Run workflow"**

##### What Happens During Release

1. **Tag Creation**: Creates a git tag with the specified version
2. **Release Creation**: Creates a GitHub release with optional title/description
3. **Binary Building**: Automatically triggers binary builds for all platforms:
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states "Binary Building: Automatically triggers binary builds for all platforms" but according to the workflow changes, the binaries.yml workflow needs to be manually triggered via workflow_dispatch or automatically triggers only when a release is created/published. The wording suggests it always automatically triggers, which could be misleading. Consider clarifying: "Binary Building: Automatically triggers when a release is created, or can be manually triggered to build binaries for all platforms".

Suggested change
3. **Binary Building**: Automatically triggers binary builds for all platforms:
3. **Binary Building**: Automatically triggers when a release is created, or can be manually triggered to build binaries for all platforms:

Copilot uses AI. Check for mistakes.
- `envsubst-Linux-x86_64` (Linux AMD64)
- `envsubst-Linux-arm64` (Linux ARM64)
- `envsubst-Darwin-x86_64` (macOS Intel)
- `envsubst-Darwin-arm64` (macOS Apple Silicon)
- `envsubst` (Windows AMD64)
4. **Asset Upload**: Binaries are automatically attached to the release

##### Rerunning Releases

- **Same Tag**: Both workflows can be rerun with the same tag name
- **Tag Exists**: The create-release workflow will skip tag creation if it already exists
- **Release Exists**: The workflow continues even if the release already exists
- **Binary Rebuild**: Use the binaries workflow to rebuild assets for existing releases

##### Supported Platforms

| Platform | Architecture | Binary Name |
|----------|---------------|--------------------------|
| Linux | AMD64 | `envsubst-Linux-x86_64` |
| Linux | ARM64 | `envsubst-Linux-arm64` |
| macOS | Intel | `envsubst-Darwin-x86_64` |
| macOS | Apple Silicon | `envsubst-Darwin-arm64` |
| Windows | AMD64 | `envsubst` |

#### License
MIT

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/a8m/envsubst

go 1.24
go 1.25.5