Error: tag ref should start with 'refs/tags/': 'refs/heads/main'; this action only supports events from tag or release by default;
Hi, did use the script at my little project - but the build fail
Error: tag ref should start with 'refs/tags/': 'refs/heads/main'; this action only supports events from tag or release by default;
What did I wrong in the script ?
name: Release for multiple platforms
on:
release:
types: [created]
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
# (optional) Path to changelog.
# changelog: CHANGELOG.md
# (required) GitHub token for creating GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}
upload-assets:
needs: create-release
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
# (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
# Note that glob pattern is not supported yet.
bin: ...
# (optional) Target triple, default is host triple.
# This is optional but it is recommended that this always be set to
# clarify which target you are building for if macOS is included in
# the matrix because GitHub Actions changed the default architecture
# of macos-latest since macos-14.
target: ${{ matrix.target }}
# (optional) On which platform to distribute the `.tar.gz` file.
# [default value: unix]
# [possible values: all, unix, windows, none]
tar: unix
# (optional) On which platform to distribute the `.zip` file.
# [default value: windows]
# [possible values: all, unix, windows, none]
zip: windows
# (required) GitHub token for uploading assets to GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}
What did I wrong in the script ?
name: Release for multiple platforms on: release: types: [created] permissions: contents: write
Please provide accurate information.
IIUC the error you are reporting actually occurred in the workflow for commit https://github.com/dd6ds/rust-morse/commit/871b115ba7d061e20fa844f5e254103c0eb87b96 or https://github.com/dd6ds/rust-morse/commit/45e6ff18a069cd6cc7ef118fccba4cf398f0009e, which has the following trigger, meaning that it is triggered by a push to any branch or tag.
on:
push:
And the log of the workflow you reported is the one that triggered by a push to the main branch, which resulted in the error you mentioned, so it is working as intended.
on: release: types: [created]
This is correct if you are creating a release manually from the GitHub release page.
However, in that case, the release already exists, so I don't understand why a create-release job is necessary.
Could you tell me specifically how you want to use it?
@taiki-e
Thanks for your help!
Could you tell me specifically how you want to use it?
I like that BINARY Packets ar BUILD when I did a git push to my project. And that zip / tgz files are overwritten when exists.
Get the Version from Cargo.toml
- name: Get version from Cargo.toml
id: get_version
run: |
version=$(grep '^version' Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/')
echo "cargo_version=$version" >> $GITHUB_OUTPUT
an get then: morse-$version-windows-x86_64.zip, morse-$version-linux-x86_64.zip, .... and morse-source-$version.zip / morse-source-$version.tar.gz
I like that BINARY Packets ar BUILD when I did a git push to my project.
In that case, I think you have to specify the push condition triggered for any branch and pass the tag name you want to use for both create-gh-release-action and upload-rust-binary-action via the ref input option.
And that zip / tgz files are overwritten when exists.
This is the default behavior.